Documentation ¶
Overview ¶
Package cid provides primitives to work with container identification in NeoFS.
Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.
Index ¶
- 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) ReadFromV2(m refs.ContainerID) error
- func (id *ID) SetSHA256(v [sha256.Size]byte)
- func (id ID) String() string
- func (id ID) WriteToV2(m *refs.ContainerID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
ID represents NeoFS container identifier.
ID is mutually compatible with github.com/nspcc-dev/neofs-api-go/v2/refs.ContainerID message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
Note that direct typecast is not safe and may result in loss of compatibility:
_ = ID([32]byte) // not recommended
func (*ID) Decode ¶
Decode decodes src bytes into ID.
Decode expects that src has 32 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.
See also Encode.
func (*ID) DecodeString ¶
DecodeString decodes string into ID according to NeoFS API protocol. Returns an error if s is malformed.
See also DecodeString.
func (ID) Encode ¶
Encode encodes ID into 32 bytes of dst. Panics if dst length is less than 32.
Zero ID is all zeros.
See also Decode.
func (ID) EncodeToString ¶
EncodeToString encodes ID into NeoFS API protocol string.
Zero ID is base58 encoding of 32 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.
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].
func (*ID) ReadFromV2 ¶
func (id *ID) ReadFromV2(m refs.ContainerID) error
ReadFromV2 reads ID from the refs.ContainerID message. Returns an error if the message is malformed according to the NeoFS API V2 protocol.
See also WriteToV2.
func (*ID) SetSHA256 ¶
SetSHA256 sets container identifier value to SHA256 checksum of container structure.
func (ID) String ¶
String implements fmt.Stringer.
String is designed to be human-readable, and its format MAY differ between SDK versions. String MAY return same result as EncodeToString. String MUST NOT be used to encode ID into NeoFS protocol string.
func (ID) WriteToV2 ¶
func (id ID) WriteToV2(m *refs.ContainerID)
WriteToV2 writes ID to the refs.ContainerID message. The message must not be nil.
See also ReadFromV2.