oid

package
v1.0.0-rc.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 57

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

View Source
const Size = sha256.Size

Size is the size of an ID in bytes.

Variables

View Source
var ErrZero = errors.New("zero object ID")

ErrZero is an error returned on zero ID encounter.

View Source
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

func DecodeAddressString(s string) (Address, error)

DecodeAddressString creates new Address and makes Address.DecodeString.

func NewAddress

func NewAddress(cnr cid.ID, obj ID) Address

NewAddress constructs new Address.

func (Address) Compare

func (x Address) Compare(other Address) int

Compare performs three-way comparison of two addresses and can be used for address list sorting.

func (Address) Container

func (x Address) Container() cid.ID

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

func (x *Address) DecodeString(s string) error

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

func (x Address) EncodeToString() string

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

func (x *Address) FromProtoMessage(m *refs.Address) error

FromProtoMessage validates m according to the NeoFS API protocol and restores x from it.

See also Address.ProtoMessage.

func (Address) IsZero

func (x Address) IsZero() bool

IsZero checks if address is zero (uninitialized).

func (Address) MarshalJSON

func (x Address) MarshalJSON() ([]byte, error)

MarshalJSON encodes Address into a JSON format of the NeoFS API protocol (Protocol Buffers JSON).

See also UnmarshalJSON.

func (Address) Object

func (x Address) Object() ID

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

func (x Address) ProtoMessage() *refs.Address

ProtoMessage converts x into message to transmit using the NeoFS API protocol.

See also Address.FromProtoMessage.

func (*Address) SetContainer

func (x *Address) SetContainer(id cid.ID)

SetContainer sets unique identifier of the NeoFS object container.

See also Container.

func (*Address) SetObject

func (x *Address) SetObject(id ID)

SetObject sets unique identifier of the object in the container identified by Container().

See also Object.

func (Address) String

func (x Address) String() 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

func (x *Address) UnmarshalJSON(data []byte) error

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

type ID [Size]byte

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

func DecodeBytes(b []byte) (ID, error)

DecodeBytes creates new ID and makes ID.Decode.

func DecodeString

func DecodeString(s string) (ID, error)

DecodeString creates new ID and makes ID.DecodeString.

func NewFromObjectHeaderBinary

func NewFromObjectHeaderBinary(b []byte) ID

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

func (id ID) Compare(other ID) int

Compare performs three-way comparison of ID and returns the result. It can be used for sorting.

func (*ID) Decode

func (id *ID) Decode(src []byte) error

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

func (id *ID) DecodeString(s string) error

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

func (id ID) EncodeToString() string

EncodeToString encodes ID into NeoFS API protocol string.

Zero ID is base58 encoding of Size zeros.

See also DecodeString.

func (*ID) FromProtoMessage

func (id *ID) FromProtoMessage(m *refs.ObjectID) error

FromProtoMessage validates m according to the NeoFS API protocol and restores id from it.

See also ID.ProtoMessage.

func (ID) IsZero

func (id ID) IsZero() bool

IsZero checks whether ID is zero.

func (ID) Marshal

func (id ID) Marshal() []byte

Marshal marshals ID into a protobuf binary form.

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON encodes ID to protobuf JSON format.

func (ID) ProtoMessage

func (id ID) ProtoMessage() *refs.ObjectID

ProtoMessage converts id into message to transmit using the NeoFS API protocol.

See also ID.FromProtoMessage.

func (ID) String

func (id ID) String() 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) Unmarshal

func (id *ID) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of ID.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes ID from protobuf JSON format.

Directories

Path Synopsis
Package oidtest provides functions for convenient testing of oid package API.
Package oidtest provides functions for convenient testing of oid package API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL