Documentation
¶
Overview ¶
Package cid provides primitives to work with container identification in NeoFS.
Index ¶
- Constants
- Variables
- type ID
- func (id *ID) Decode(src []byte) error
- func (id *ID) DecodeString(s string) error
- func (id ID) Encode(dst []byte)
- func (id ID) EncodeToString() string
- func (id ID) Equals(id2 ID) bool
- func (id *ID) FromBinary(cnr []byte)
- func (id *ID) FromProtoMessage(m *refs.ContainerID) error
- func (id ID) IsZero() bool
- func (id ID) ProtoMessage() *refs.ContainerID
- func (id *ID) SetSHA256(v [sha256.Size]byte)
- func (id ID) String() string
Constants ¶
const Size = sha256.Size
Size is the size of an ID in bytes.
Variables ¶
var ErrZero = errors.New("zero container ID")
ErrZero is an error returned on zero ID encounter.
Functions ¶
This section is empty.
Types ¶
type ID ¶
ID represents NeoFS container identifier. Zero ID is usually prohibited, see docs for details.
ID implements built-in comparable interface.
ID is mutually compatible with refs.ContainerID message. See ID.FromProtoMessage / ID.ProtoMessage methods.
func DecodeBytes ¶
DecodeBytes creates new ID and makes ID.Decode.
func DecodeString ¶
DecodeString creates new ID and makes ID.DecodeString.
func NewFromMarshalledContainer ¶
NewFromMarshalledContainer returns new ID calculated from the given NeoFS container encoded into Protocol Buffers V3 with ascending order of fields by number. It's callers responsibility to ensure the format of b. See [container.Container.Marshal].
func (*ID) Decode ¶
Decode decodes src bytes into ID. Use DecodeBytes to decode src into a new ID.
Decode expects that src has Size bytes length. If the input is malformed, Decode returns an error describing format violation. In this case ID remains unchanged.
Decode doesn't mutate src.
func (*ID) DecodeString ¶
DecodeString decodes string into ID according to NeoFS API protocol. Returns an error if s is malformed. Use DecodeString to decode s into a new ID.
See also DecodeString.
func (ID) Encode ¶
Encode encodes ID into Size bytes of dst. Panics if dst length is less than Size.
Zero ID is all zeros.
See also Decode. Deprecated: use id[:] instead.
func (ID) EncodeToString ¶
EncodeToString encodes ID into NeoFS API protocol string.
Zero ID is base58 encoding of Size zeros.
See also DecodeString.
func (ID) Equals ¶
Equals defines a comparison relation between two ID instances.
Note that comparison using '==' operator is not recommended since it MAY result in loss of compatibility. Deprecated: ID is comparable.
func (*ID) FromBinary ¶
FromBinary calculates identifier of the binary-encoded container in CAS of the NeoFS containers and writes it into id.
See also [container.Container.CalculateID], [container.Container.AssertID]. Deprecated: use [NewFromContainerBinary].
func (*ID) FromProtoMessage ¶
func (id *ID) FromProtoMessage(m *refs.ContainerID) error
FromProtoMessage validates m according to the NeoFS API protocol and restores id from it.
See also ID.ProtoMessage.
func (ID) ProtoMessage ¶
func (id ID) ProtoMessage() *refs.ContainerID
ProtoMessage converts id into message to transmit using the NeoFS API protocol.
See also ID.FromProtoMessage.