Documentation
¶
Overview ¶
Package oid provides primitives to work with object identification in NeoFS.
Address type is used for global object identity inside the NeoFS network, while ID represents identity within a fixed container.
Index ¶
- Constants
- Variables
- type Address
- func (x Address) Compare(other Address) int
- func (x Address) Container() cid.ID
- func (x *Address) DecodeString(s string) error
- func (x Address) EncodeToString() string
- func (x *Address) FromProtoMessage(m *refs.Address) error
- func (x Address) IsZero() bool
- func (x Address) MarshalJSON() ([]byte, error)
- func (x Address) Object() ID
- func (x Address) ProtoMessage() *refs.Address
- func (x *Address) SetContainer(id cid.ID)
- func (x *Address) SetObject(id ID)
- func (x Address) String() string
- func (x *Address) UnmarshalJSON(data []byte) error
- type ID
- func (id ID) CalculateIDSignature(signer neofscrypto.Signer) (neofscrypto.Signature, error)
- func (id ID) Compare(other ID) int
- func (id *ID) Decode(src []byte) error
- func (id *ID) DecodeString(s string) error
- func (id ID) EncodeToString() string
- func (id *ID) FromProtoMessage(m *refs.ObjectID) error
- func (id ID) IsZero() bool
- func (id ID) Marshal() []byte
- func (id ID) MarshalJSON() ([]byte, error)
- func (id ID) ProtoMessage() *refs.ObjectID
- func (id ID) String() string
- func (id *ID) Unmarshal(data []byte) error
- func (id *ID) UnmarshalJSON(data []byte) error
Constants ¶
const Size = sha256.Size
Size is the size of an ID in bytes.
Variables ¶
var ErrZero = errors.New("zero object ID")
ErrZero is an error returned on zero ID encounter.
var ErrZeroAddress = errors.New("zero object address")
ErrZeroAddress is an error returned on zero Address encounter.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address represents global object identifier in NeoFS network. Each object belongs to exactly one container and is uniquely addressed within the container. Zero Address is usually prohibited, see docs for details.
ID implements built-in comparable interface.
Address is mutually compatible with refs.Address message. See Address.FromProtoMessage / Address.ProtoMessage methods.
func DecodeAddressString ¶
DecodeAddressString creates new Address and makes Address.DecodeString.
func (Address) Compare ¶
Compare performs three-way comparison of two addresses and can be used for address list sorting.
func (Address) Container ¶
Container returns unique identifier of the NeoFS object container.
Zero Address has zero container ID, which is incorrect according to NeoFS API protocol.
See also SetContainer.
func (*Address) DecodeString ¶
DecodeString decodes string into Address according to NeoFS API protocol. Returns an error if s is malformed. Use DecodeAddressString to decode s into a new ID.
See also DecodeString.
func (Address) EncodeToString ¶
EncodeToString encodes Address into NeoFS API protocol string: concatenation of the string-encoded container and object IDs delimited by a slash.
See also DecodeString.
func (*Address) FromProtoMessage ¶
FromProtoMessage validates m according to the NeoFS API protocol and restores x from it.
See also Address.ProtoMessage.
func (Address) MarshalJSON ¶
MarshalJSON encodes Address into a JSON format of the NeoFS API protocol (Protocol Buffers JSON).
See also UnmarshalJSON.
func (Address) Object ¶
Object returns unique identifier of the object in the container identified by Container().
Zero Address has zero object ID, which is incorrect according to NeoFS API protocol.
See also SetObject.
func (Address) ProtoMessage ¶
ProtoMessage converts x into message to transmit using the NeoFS API protocol.
See also Address.FromProtoMessage.
func (*Address) SetContainer ¶
SetContainer sets unique identifier of the NeoFS object container.
See also Container.
func (*Address) SetObject ¶
SetObject sets unique identifier of the object in the container identified by Container().
See also Object.
func (Address) 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 Address into NeoFS protocol string.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON decodes NeoFS API protocol JSON format into the Address (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
type ID ¶
ID represents NeoFS object identifier in a container. Zero ID is usually prohibited, see docs for details.
ID implements built-in comparable interface.
ID is mutually compatible with refs.ObjectID 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 NewFromObjectHeaderBinary ¶
NewFromObjectHeaderBinary returns new ID calculated from the given NeoFS object header encoded into Protocol Buffers V3 with ascending order of fields by number. It's callers responsibility to ensure the format of b.
func (ID) CalculateIDSignature ¶
func (id ID) CalculateIDSignature(signer neofscrypto.Signer) (neofscrypto.Signature, error)
CalculateIDSignature signs object id with provided key.
func (ID) Compare ¶
Compare performs three-way comparison of ID and returns the result. It can be used for sorting.
func (*ID) Decode ¶
Decode decodes src bytes into ID. Use DecodeBytes to decode src into a new ID.
Decode expects that src has [IDSize] 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) EncodeToString ¶
EncodeToString encodes ID into NeoFS API protocol string.
Zero ID is base58 encoding of Size zeros.
See also DecodeString.
func (*ID) FromProtoMessage ¶
FromProtoMessage validates m according to the NeoFS API protocol and restores id from it.
See also ID.ProtoMessage.
func (ID) MarshalJSON ¶
MarshalJSON encodes ID to protobuf JSON format.
func (ID) ProtoMessage ¶
ProtoMessage converts id into message to transmit using the NeoFS API protocol.
See also ID.FromProtoMessage.
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) UnmarshalJSON ¶
UnmarshalJSON decodes ID from protobuf JSON format.