Documentation ¶
Overview ¶
Package oid provides primitives to work with object identification in FrostFS.
Address type is used for global object identity inside the FrostFS network, while ID represents identity within a fixed container.
Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.
Index ¶
- type Address
- func (x Address) Container() cid.ID
- func (x *Address) DecodeString(s string) error
- func (x Address) EncodeToString() string
- func (x Address) MarshalJSON() ([]byte, error)
- func (x Address) Object() ID
- func (x *Address) ReadFromV2(m refs.Address) error
- 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
- func (x Address) WriteToV2(m *refs.Address)
- type ID
- func (id ID) CalculateIDSignature(key ecdsa.PrivateKey) (frostfscrypto.Signature, error)
- 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) Marshal() ([]byte, error)
- func (id ID) MarshalJSON() ([]byte, error)
- func (id *ID) ReadFromV2(m refs.ObjectID) error
- func (id *ID) SetSHA256(v [sha256.Size]byte)
- func (id ID) String() string
- func (id *ID) Unmarshal(data []byte) error
- func (id *ID) UnmarshalJSON(data []byte) error
- func (id ID) WriteToV2(m *refs.ObjectID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address represents global object identifier in FrostFS network. Each object belongs to exactly one container and is uniquely addressed within the container.
Address is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/refs.Address message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration.
func (Address) Container ¶
Container returns unique identifier of the FrostFS object container.
Zero Address has zero container ID, which is incorrect according to FrostFS API protocol.
See also SetContainer.
func (*Address) DecodeString ¶
DecodeString decodes string into Address according to FrostFS API protocol. Returns an error if s is malformed.
See also DecodeString.
func (Address) EncodeToString ¶
EncodeToString encodes Address into FrostFS API protocol string: concatenation of the string-encoded container and object IDs delimited by a slash.
See also DecodeString.
func (Address) MarshalJSON ¶
MarshalJSON encodes Address into a JSON format of the FrostFS 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 FrostFS API protocol.
See also SetObject.
func (*Address) ReadFromV2 ¶
ReadFromV2 reads Address from the refs.Address message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.
See also WriteToV2.
func (*Address) SetContainer ¶
SetContainer sets unique identifier of the FrostFS 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 FrostFS protocol string.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON decodes FrostFS API protocol JSON format into the Address (Protocol Buffers JSON). Returns an error describing a format violation.
See also MarshalJSON.
type ID ¶
ID represents FrostFS object identifier in a container.
ID is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/refs.ObjectID 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) CalculateIDSignature ¶
func (id ID) CalculateIDSignature(key ecdsa.PrivateKey) (frostfscrypto.Signature, error)
CalculateIDSignature signs object id with provided key.
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 FrostFS 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 FrostFS 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) MarshalJSON ¶
MarshalJSON encodes ID to protobuf JSON format.
func (*ID) ReadFromV2 ¶
ReadFromV2 reads ID from the refs.ObjectID message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.
See also WriteToV2.
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 FrostFS protocol string.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON decodes ID from protobuf JSON format.