object

package
v1.0.0-rc.16 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 24 Imported by: 59

Documentation

Index

Examples

Constants

View Source
const (

	// AttributeExpirationEpoch is a key to an object attribute that determines
	// after what epoch the object becomes expired. Objects that do not have this
	// attribute never expire.
	//
	// Reaction of NeoFS system components to the objects' 'expired' property may
	// vary. For example, in the basic scenario, expired objects are auto-deleted
	// from the storage. Detailed behavior can be found in the NeoFS Specification.
	//
	// Note that the value determines exactly the last epoch of the object's
	// relevance: for example, with the value N, the object is relevant in epoch N
	// and expired in any epoch starting from N+1.
	AttributeExpirationEpoch = sysAttrPrefix + "EXPIRATION_EPOCH"
	// AttributeAssociatedObject is a key to an object attribute that determines
	// associated object's ID. For [object.TypeTombstone] it defines object to
	// delete. For [object.TypeLock] it defines object to lock.
	AttributeAssociatedObject = sysAttrPrefix + "ASSOCIATE"
	// AttributeECPrefix is a prefix of EC object attributes.
	AttributeECPrefix = sysAttrPrefix + "EC_"
	// AttributeECRuleIndex is an attribute of EC part object specifying index of EC
	// rule in container storage policy according to which the part was created.
	// Value is base-10 integer.
	AttributeECRuleIndex = AttributeECPrefix + "RULE_IDX"
	// AttributeECPartIndex is an attribute of EC part object specifying index in
	// the EC parts into which the parent object is divided. Value is base-10
	// integer.
	AttributeECPartIndex = AttributeECPrefix + "PART_IDX"
)

Various system attributes.

View Source
const (
	FilterVersion                = reservedFilterPrefix + "version"
	FilterID                     = reservedFilterPrefix + "objectID"    // Deprecated.
	FilterContainerID            = reservedFilterPrefix + "containerID" // Deprecated.
	FilterOwnerID                = reservedFilterPrefix + "ownerID"
	FilterPayloadChecksum        = reservedFilterPrefix + "payloadHash"
	FilterType                   = reservedFilterPrefix + "objectType"
	FilterPayloadHomomorphicHash = reservedFilterPrefix + "homomorphicHash"
	FilterParentID               = reservedFilterPrefix + "split.parent"
	FilterSplitID                = reservedFilterPrefix + "split.splitID"
	FilterFirstSplitObject       = reservedFilterPrefix + "split.first"
	FilterCreationEpoch          = reservedFilterPrefix + "creationEpoch"
	FilterPayloadSize            = reservedFilterPrefix + "payloadLength"
)

Various header filters.

View Source
const (
	// FilterRoot filters objects that are root: objects of TypeRegular type
	// with user data that are not system-specific. In addition to such objects, the
	// system may contain service objects that do not fall under this property
	// (like split leaves, tombstones, storage groups, etc.).
	FilterRoot = reservedFilterPrefix + "ROOT"
	// FilterPhysical filters indivisible objects that are intended to be stored
	// on the physical devices of the system. In addition to such objects, the
	// system may contain so-called "virtual" objects that exist in the system in
	// disassembled form (like "huge" user object sliced into smaller ones).
	FilterPhysical = reservedFilterPrefix + "PHY"
)

Various filters to match certain object properties.

View Source
const (
	// AttributeName is an attribute key that is commonly used to denote
	// human-friendly name.
	AttributeName = "Name"

	// AttributeFileName is an attribute key that is commonly used to denote
	// file name to be associated with the object on saving.
	AttributeFileName = "FileName"

	// AttributeFilePath is an attribute key that is commonly used to denote
	// full path to be associated with the object on saving. Should start with a
	// '/' and use '/' as a delimiting symbol. Trailing '/' should be
	// interpreted as a virtual directory marker. If an object has conflicting
	// FilePath and FileName, FilePath should have higher priority, because it
	// is used to construct the directory tree. FilePath with trailing '/' and
	// non-empty FileName attribute should not be used together.
	AttributeFilePath = "FilePath"

	// AttributeTimestamp is an attribute key that is commonly used to denote
	// user-defined local time of object creation in Unix Timestamp format.
	AttributeTimestamp = "Timestamp"

	// AttributeContentType is an attribute key that is commonly used to denote
	// MIME Content Type of object's payload.
	AttributeContentType = "Content-Type"
)
View Source
const MaxHeaderLen = 16 << 10

MaxHeaderLen is a maximum allowed length of binary object header to be created via NeoFS API protocol.

Variables

This section is empty.

Functions

func CalculatePayloadChecksum

func CalculatePayloadChecksum(payload []byte) checksum.Checksum

CalculatePayloadChecksum calculates and returns checksum of object payload bytes.

Types

type Attribute

type Attribute struct {
	// contains filtered or unexported fields
}

Attribute represents an object attribute.

func NewAttribute

func NewAttribute(key, value string) Attribute

NewAttribute creates and initializes new Attribute.

func (*Attribute) Key

func (a *Attribute) Key() string

Key returns key to the object attribute.

func (*Attribute) Marshal

func (a *Attribute) Marshal() []byte

Marshal marshals Attribute into a protobuf binary form.

See also Attribute.Unmarshal.

func (*Attribute) MarshalJSON

func (a *Attribute) MarshalJSON() ([]byte, error)

MarshalJSON encodes Attribute to protobuf JSON format.

See also Attribute.UnmarshalJSON.

func (*Attribute) SetKey

func (a *Attribute) SetKey(v string)

SetKey sets key to the object attribute.

func (*Attribute) SetValue

func (a *Attribute) SetValue(v string)

SetValue sets value of the object attribute.

func (*Attribute) Unmarshal

func (a *Attribute) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of Attribute.

See also Attribute.Marshal.

func (*Attribute) UnmarshalJSON

func (a *Attribute) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Attribute from protobuf JSON format.

See also Attribute.MarshalJSON.

func (*Attribute) Value

func (a *Attribute) Value() string

Value return value of the object attribute.

type Link struct {
	// contains filtered or unexported fields
}

Link is a payload of helper objects that contain the full list of the split chain of the big NeoFS objects. It is compatible with NeoFS API V2 protocol.

Link instance can be written to the Object, see Object.WriteLink/Object.ReadLink.

func (*Link) Marshal

func (l *Link) Marshal() []byte

Marshal encodes the Link into a NeoFS protocol binary format.

See also Link.Unmarshal.

func (*Link) Objects

func (l *Link) Objects() []MeasuredObject

Objects returns split chain's measured objects.

See also Link.SetObjects.

func (*Link) SetObjects

func (l *Link) SetObjects(oo []MeasuredObject)

SetObjects sets split chain's measured objects.

See also Link.Objects.

func (*Link) Unmarshal

func (l *Link) Unmarshal(data []byte) error

Unmarshal decodes the Link from its NeoFS protocol binary representation.

See also Link.Marshal.

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock represents record with locked objects. It is compatible with NeoFS API V2 protocol.

Lock instance can be written to the Object, see WriteLock/ReadLock.

DEPRECATED: use Object.AssociateLocked instead, locking exactly one object per Lock.

func (Lock) Marshal

func (x Lock) Marshal() []byte

Marshal encodes the Lock into a NeoFS protocol binary format.

See also Lock.Unmarshal.

func (Lock) NumberOfMembers

func (x Lock) NumberOfMembers() int

NumberOfMembers returns number of members in lock list.

func (Lock) ReadMembers

func (x Lock) ReadMembers(buf []oid.ID)

ReadMembers reads list of locked members.

Buffer length must not be less than Lock.NumberOfMembers.

func (*Lock) Unmarshal

func (x *Lock) Unmarshal(data []byte) error

Unmarshal decodes the Lock from its NeoFS protocol binary representation.

See also Lock.Marshal.

func (*Lock) WriteMembers

func (x *Lock) WriteMembers(ids []oid.ID)

WriteMembers writes list of locked members.

See also Lock.ReadMembers.

type MeasuredObject

type MeasuredObject struct {
	// contains filtered or unexported fields
}

MeasuredObject groups object ID and its size length.

func (*MeasuredObject) ObjectID

func (m *MeasuredObject) ObjectID() oid.ID

ObjectID returns object identifier.

See also MeasuredObject.SetObjectID.

func (*MeasuredObject) ObjectSize

func (m *MeasuredObject) ObjectSize() uint32

ObjectSize returns size of the object.

See also MeasuredObject.SetObjectSize.

func (*MeasuredObject) SetObjectID

func (m *MeasuredObject) SetObjectID(id oid.ID)

SetObjectID sets object identifier.

See also MeasuredObject.ObjectID.

func (*MeasuredObject) SetObjectSize

func (m *MeasuredObject) SetObjectSize(s uint32)

SetObjectSize sets size of the object.

See also MeasuredObject.ObjectSize.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object represents in-memory structure of the NeoFS object. Type is compatible with NeoFS API V2 protocol.

Instance can be created depending on scenario:

func New

func New() *Object

New creates and initializes blank Object.

func (*Object) AssociateDeleted

func (o *Object) AssociateDeleted(id oid.ID)

AssociateDeleted makes this object to delete another object. See also object.AttributeAssociatedObject.

func (*Object) AssociateLocked

func (o *Object) AssociateLocked(id oid.ID)

AssociateLocked makes this object to lock another object from deletion. See also object.AttributeAssociatedObject.

func (*Object) AssociateObject

func (o *Object) AssociateObject(id oid.ID)

AssociateObject associates object with the current one. See also object.AttributeAssociatedObject attribute.

func (*Object) AssociatedObject

func (o *Object) AssociatedObject() oid.ID

AssociatedObject returns associated object with the current one. Returns zero object ID of no association has been made or if associated object ID is incorrect. If more than one association has been made, retuned result is undefined. See also object.AttributeAssociatedObject.

func (Object) Attributes

func (o Object) Attributes() []Attribute

Attributes returns all object attributes.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

See also Object.SetAttributes, Object.UserAttributes.

func (*Object) CalculateAndSetID

func (o *Object) CalculateAndSetID() error

CalculateAndSetID calculates identifier for the object and writes the result to it.

func (*Object) CalculateAndSetPayloadChecksum

func (o *Object) CalculateAndSetPayloadChecksum()

CalculateAndSetPayloadChecksum calculates checksum of current object payload and writes it to the object.

func (Object) CalculateID

func (o Object) CalculateID() (oid.ID, error)

CalculateID calculates identifier for the object.

func (Object) CheckHeaderVerificationFields

func (o Object) CheckHeaderVerificationFields() error

CheckHeaderVerificationFields checks all verification fields except payload.

func (Object) CheckVerificationFields

func (o Object) CheckVerificationFields() error

CheckVerificationFields checks all verification fields of the object.

func (Object) Children

func (o Object) Children() []oid.ID

Children return list of the identifiers of the child objects.

See also Object.SetChildren.

func (Object) CopyTo

func (o Object) CopyTo(dst *Object)

CopyTo writes deep copy of the Object to dst.

func (Object) CreationEpoch

func (o Object) CreationEpoch() uint64

CreationEpoch returns epoch number in which object was created.

See also Object.SetCreationEpoch.

func (*Object) CutPayload

func (o *Object) CutPayload() *Object

CutPayload returns Object w/ empty payload.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

func (Object) FirstID

func (o Object) FirstID() (oid.ID, bool)

FirstID returns the first part of the object's split chain.

See also Object.SetFirstID.

func (*Object) FromProtoMessage

func (o *Object) FromProtoMessage(m *protoobject.Object) error

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

See also [Table.ProtoMessage].

func (Object) GetContainerID

func (o Object) GetContainerID() cid.ID

GetContainerID returns identifier of the related container. Zero means unset binding.

See also Object.SetContainerID.

func (Object) GetFirstID

func (o Object) GetFirstID() oid.ID

GetFirstID returns the first part of the object's split chain. Zero return means unset ID.

See also Object.SetFirstID.

func (Object) GetID

func (o Object) GetID() oid.ID

GetID returns identifier of the object. Zero return means unset ID.

See also Object.SetID.

func (Object) GetParentID

func (o Object) GetParentID() oid.ID

GetParentID returns identifier of the parent object. Zero return means unset ID.

See also Object.SetParentID.

func (Object) GetPreviousID

func (o Object) GetPreviousID() oid.ID

GetPreviousID returns identifier of the previous sibling object. Zero return means unset ID.

See also Object.SetPreviousID.

func (Object) HasParent

func (o Object) HasParent() bool

HasParent checks if parent (split ID) is present.

func (Object) HeaderLen

func (o Object) HeaderLen() int

HeaderLen returns length of the binary header.

func (*Object) InitCreation

func (o *Object) InitCreation(rf RequiredFields)

InitCreation initializes the object instance with minimum set of required fields.

func (Object) Marshal

func (o Object) Marshal() []byte

Marshal marshals object into a protobuf binary form.

See also Object.Unmarshal.

func (Object) MarshalHeaderJSON

func (o Object) MarshalHeaderJSON() ([]byte, error)

MarshalHeaderJSON marshals object's header into JSON format.

func (Object) MarshalJSON

func (o Object) MarshalJSON() ([]byte, error)

MarshalJSON encodes object to protobuf JSON format.

See also Object.UnmarshalJSON.

func (Object) Owner

func (o Object) Owner() user.ID

Owner returns user ID of the object owner. Zero return means unset ID.

See also Object.SetOwner.

func (Object) Parent

func (o Object) Parent() *Object

Parent returns parent object w/o payload.

See also Object.SetParent.

func (Object) Payload

func (o Object) Payload() []byte

Payload returns payload bytes.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

See also Object.SetPayload.

func (Object) PayloadChecksum

func (o Object) PayloadChecksum() (checksum.Checksum, bool)

PayloadChecksum returns checksum of the object payload and bool that indicates checksum presence in the object.

Zero Object does not have payload checksum.

See also Object.SetPayloadChecksum.

func (Object) PayloadHomomorphicHash

func (o Object) PayloadHomomorphicHash() (checksum.Checksum, bool)

PayloadHomomorphicHash returns homomorphic hash of the object payload and bool that indicates checksum presence in the object.

Zero Object does not have payload homomorphic checksum.

See also Object.SetPayloadHomomorphicHash.

func (Object) PayloadSize

func (o Object) PayloadSize() uint64

PayloadSize returns payload length of the object.

See also Object.SetPayloadSize.

func (Object) ProtoMessage

func (o Object) ProtoMessage() *protoobject.Object

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

See also Object.FromProtoMessage.

func (o Object) ReadLink(l *Link) error

ReadLink reads a link from the Object. The link must not be nil. Returns an error describing incorrect format. Makes sense only if the object has TypeLink type.

See also Object.WriteLink.

func (Object) ReadLock

func (o Object) ReadLock(l *Lock) error

ReadLock reads Lock from the Object. The lock must not be nil. Returns an error describing incorrect format. Makes sense only if object has TypeLock type.

See also Object.WriteLock.

func (*Object) ResetID

func (o *Object) ResetID()

ResetID removes object identifier.

See also Object.SetID.

func (*Object) ResetParentID

func (o *Object) ResetParentID()

ResetParentID removes identifier of the parent object.

See also Object.SetParentID.

func (*Object) ResetPreviousID

func (o *Object) ResetPreviousID()

ResetPreviousID resets identifier of the previous sibling object.

See also Object.SetPreviousID, Object.GetPreviousID.

func (*Object) ResetRelations

func (o *Object) ResetRelations()

ResetRelations removes all fields of links with other objects.

func (Object) SessionToken

func (o Object) SessionToken() *session.Object

SessionToken returns token of the session within which object was created.

See also Object.SetSessionToken.

func (*Object) SetAttributes

func (o *Object) SetAttributes(v ...Attribute)

SetAttributes sets object attributes.

func (*Object) SetChildren

func (o *Object) SetChildren(v ...oid.ID)

SetChildren sets list of the identifiers of the child objects.

See also Object.Children.

func (*Object) SetContainerID

func (o *Object) SetContainerID(v cid.ID)

SetContainerID sets identifier of the related container.

See also Object.GetContainerID.

func (*Object) SetCreationEpoch

func (o *Object) SetCreationEpoch(v uint64)

SetCreationEpoch sets epoch number in which object was created.

See also Object.CreationEpoch.

func (*Object) SetFirstID

func (o *Object) SetFirstID(id oid.ID)

SetFirstID sets the first part's ID of the object's split chain.

See also Object.GetFirstID.

func (*Object) SetID

func (o *Object) SetID(v oid.ID)

SetID sets object identifier.

See also Object.GetID.

func (*Object) SetIDWithSignature

func (o *Object) SetIDWithSignature(signer neofscrypto.Signer) error

SetIDWithSignature sets object identifier and signature.

func (*Object) SetOwner

func (o *Object) SetOwner(v user.ID)

SetOwner sets identifier of the object owner.

See also [Object.GetOwner].

func (*Object) SetParent

func (o *Object) SetParent(v *Object)

SetParent sets parent object w/o payload.

See also Object.Parent.

func (*Object) SetParentID

func (o *Object) SetParentID(v oid.ID)

SetParentID sets identifier of the parent object.

See also Object.GetParentID.

func (*Object) SetPayload

func (o *Object) SetPayload(v []byte)

SetPayload sets payload bytes.

See also Object.Payload.

func (*Object) SetPayloadChecksum

func (o *Object) SetPayloadChecksum(v checksum.Checksum)

SetPayloadChecksum sets checksum of the object payload.

See also Object.PayloadChecksum.

func (*Object) SetPayloadHomomorphicHash

func (o *Object) SetPayloadHomomorphicHash(v checksum.Checksum)

SetPayloadHomomorphicHash sets homomorphic hash of the object payload.

See also Object.PayloadHomomorphicHash.

func (*Object) SetPayloadSize

func (o *Object) SetPayloadSize(v uint64)

SetPayloadSize sets payload length of the object.

See also Object.PayloadSize.

func (*Object) SetPreviousID

func (o *Object) SetPreviousID(v oid.ID)

SetPreviousID sets identifier of the previous sibling object.

See also Object.GetPreviousID.

func (*Object) SetSessionToken

func (o *Object) SetSessionToken(v *session.Object)

SetSessionToken sets token of the session within which object was created.

See also Object.SessionToken.

func (*Object) SetSignature

func (o *Object) SetSignature(v *neofscrypto.Signature)

SetSignature sets signature of the object identifier.

See also Object.Signature.

func (*Object) SetSplitID

func (o *Object) SetSplitID(id *SplitID)

SetSplitID sets split identifier for the split object.

See also Object.SplitID.

func (*Object) SetType

func (o *Object) SetType(v Type)

SetType sets type of the object.

See also Object.Type.

func (*Object) SetVerificationFields

func (o *Object) SetVerificationFields(signer neofscrypto.Signer) error

SetVerificationFields calculates and sets all verification fields of the object.

func (*Object) SetVersion

func (o *Object) SetVersion(v *version.Version)

SetVersion sets version of the object.

See also Object.Version.

func (*Object) Sign

func (o *Object) Sign(signer neofscrypto.Signer) error

Sign signs object id with provided key and sets that signature to the object.

See also oid.ID.CalculateIDSignature.

func (Object) Signature

func (o Object) Signature() *neofscrypto.Signature

Signature returns signature of the object identifier.

See also Object.SetSignature.

func (Object) SignedData

func (o Object) SignedData() []byte

SignedData returns actual payload to sign.

See also Object.Sign.

func (Object) SplitID

func (o Object) SplitID() *SplitID

SplitID return split identity of split object. If object is not split returns nil.

See also Object.SetSplitID.

func (Object) Type

func (o Object) Type() Type

Type returns type of the object.

See also Object.SetType.

func (*Object) Unmarshal

func (o *Object) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of object.

See also Object.Marshal.

func (*Object) UnmarshalJSON

func (o *Object) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes object from protobuf JSON format.

See also Object.MarshalJSON.

func (Object) UserAttributes

func (o Object) UserAttributes() []Attribute

UserAttributes returns user attributes of the Object.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

See also Object.SetAttributes, Object.Attributes.

func (Object) VerifyID

func (o Object) VerifyID() error

VerifyID checks if identifier in the object corresponds to its structure.

func (Object) VerifyPayloadChecksum

func (o Object) VerifyPayloadChecksum() error

VerifyPayloadChecksum checks if payload checksum in the object corresponds to its payload.

func (Object) VerifySignature

func (o Object) VerifySignature() bool

VerifySignature verifies object ID signature.

func (Object) Version

func (o Object) Version() *version.Version

Version returns version of the object. Returns nil if the version is unset.

See also Object.SetVersion.

func (o *Object) WriteLink(l Link)

WriteLink writes a link to the Object, and sets its type to TypeLink.

See also ReadLink.

func (*Object) WriteLock

func (o *Object) WriteLock(l Lock)

WriteLock writes Lock to the Object, and sets its type to TypeLock.

See also ReadLock.

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range represents v2 object.Range object payload range.

func NewRange

func NewRange() *Range

NewRange creates and initializes blank Range.

Defaults:

  • offset: 0;
  • length: 0.

func (*Range) GetLength

func (r *Range) GetLength() uint64

GetLength returns payload range size.

See also Range.SetLength.

func (*Range) GetOffset

func (r *Range) GetOffset() uint64

GetOffset sets payload range offset from start.

See also Range.SetOffset.

func (*Range) SetLength

func (r *Range) SetLength(v uint64)

SetLength sets payload range size.

See also Range.GetLength.

func (*Range) SetOffset

func (r *Range) SetOffset(v uint64)

SetOffset gets payload range offset from start.

See also Range.GetOffset.

type RequiredFields

type RequiredFields struct {
	// Identifier of the NeoFS container associated with the object.
	Container cid.ID

	// Object owner's user ID in the NeoFS system.
	Owner user.ID
}

RequiredFields contains the minimum set of object data that must be set by the NeoFS user at the stage of creation.

type SearchFilter

type SearchFilter struct {
	// contains filtered or unexported fields
}

SearchFilter describes a single filter record.

func (SearchFilter) Header

func (f SearchFilter) Header() string

Header returns filter header value.

func (SearchFilter) IsNonAttribute

func (f SearchFilter) IsNonAttribute() bool

IsNonAttribute checks if SearchFilter is non-attribute: such filter is related to the particular property of the object instead of its attribute.

func (SearchFilter) Operation

func (f SearchFilter) Operation() SearchMatchType

Operation returns filter operation value.

func (SearchFilter) Value

func (f SearchFilter) Value() string

Value returns filter value.

type SearchFilters

type SearchFilters []SearchFilter

SearchFilters is type to describe a group of filters.

func NewSearchFilters

func NewSearchFilters() SearchFilters

NewSearchFilters constructs empty filter group.

func (*SearchFilters) AddCreationEpochFilter

func (f *SearchFilters) AddCreationEpochFilter(m SearchMatchType, epoch uint64)

AddCreationEpochFilter adds filter by creation epoch.

func (*SearchFilters) AddFilter

func (f *SearchFilters) AddFilter(key, value string, op SearchMatchType)

AddFilter adds a filter to group by simple plain parameters.

If op is numeric (like MatchNumGT), value must be a base-10 integer.

func (*SearchFilters) AddFirstSplitObjectFilter

func (f *SearchFilters) AddFirstSplitObjectFilter(m SearchMatchType, id oid.ID)

AddFirstSplitObjectFilter adds filter by first object ID.

The m must not be numeric (like MatchNumGT).

func (*SearchFilters) AddHomomorphicHashFilter

func (f *SearchFilters) AddHomomorphicHashFilter(m SearchMatchType, sum [tz.Size]byte)

AddHomomorphicHashFilter adds filter by homomorphic hash.

The m must not be numeric (like MatchNumGT).

Example
package main

import (
	"encoding/hex"
	"fmt"

	"github.com/nspcc-dev/neofs-sdk-go/checksum"
	"github.com/nspcc-dev/tzhash/tz"
)

func main() {
	hash, _ := hex.DecodeString("7e302ebb3937e810feb501965580c746048db99cebd095c3ce27022407408bf904dde8d9aa8085d2cf7202345341cc947fa9d722c6b6699760d307f653815d0c")
	cs := checksum.NewTillichZemor([tz.Size]byte(hash))
	fmt.Println(hex.EncodeToString(cs.Value()))
}
Output:

7e302ebb3937e810feb501965580c746048db99cebd095c3ce27022407408bf904dde8d9aa8085d2cf7202345341cc947fa9d722c6b6699760d307f653815d0c

func (*SearchFilters) AddObjectOwnerIDFilter

func (f *SearchFilters) AddObjectOwnerIDFilter(m SearchMatchType, id user.ID)

AddObjectOwnerIDFilter adds a filter by object owner id.

The m must not be numeric (like MatchNumGT).

func (*SearchFilters) AddObjectVersionFilter

func (f *SearchFilters) AddObjectVersionFilter(op SearchMatchType, v version.Version)

AddObjectVersionFilter adds a filter by version.

The op must not be numeric (like MatchNumGT).

func (*SearchFilters) AddParentIDFilter

func (f *SearchFilters) AddParentIDFilter(m SearchMatchType, id oid.ID)

AddParentIDFilter adds filter by parent identifier.

The m must not be numeric (like MatchNumGT).

func (*SearchFilters) AddPayloadHashFilter

func (f *SearchFilters) AddPayloadHashFilter(m SearchMatchType, sum [sha256.Size]byte)

AddPayloadHashFilter adds filter by payload hash.

The m must not be numeric (like MatchNumGT).

Example
package main

import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"

	"github.com/nspcc-dev/neofs-sdk-go/checksum"
)

func main() {
	hash, _ := hex.DecodeString("66842cfea090b1d906b52400fae49d86df078c0670f2bdd059ba289ebe24a498")
	cs := checksum.NewSHA256([sha256.Size]byte(hash))
	fmt.Println(hex.EncodeToString(cs.Value()))
}
Output:

66842cfea090b1d906b52400fae49d86df078c0670f2bdd059ba289ebe24a498

func (*SearchFilters) AddPayloadSizeFilter

func (f *SearchFilters) AddPayloadSizeFilter(m SearchMatchType, size uint64)

AddPayloadSizeFilter adds filter by payload size.

func (*SearchFilters) AddPhyFilter

func (f *SearchFilters) AddPhyFilter()

AddPhyFilter adds filter by objects that are physically stored in the system.

func (*SearchFilters) AddRootFilter

func (f *SearchFilters) AddRootFilter()

AddRootFilter adds filter by objects that have been created by a user explicitly.

func (*SearchFilters) AddSplitIDFilter

func (f *SearchFilters) AddSplitIDFilter(m SearchMatchType, id SplitID)

AddSplitIDFilter adds filter by split ID.

The m must not be numeric (like MatchNumGT).

func (*SearchFilters) AddTypeFilter

func (f *SearchFilters) AddTypeFilter(m SearchMatchType, typ Type)

AddTypeFilter adds filter by object type.

The m must not be numeric (like MatchNumGT).

func (*SearchFilters) FromProtoMessage

func (f *SearchFilters) FromProtoMessage(ms []*protoobject.SearchFilter) error

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

See also SearchFilters.ProtoMessage.

func (SearchFilters) MarshalJSON

func (f SearchFilters) MarshalJSON() ([]byte, error)

MarshalJSON encodes SearchFilters to protobuf JSON format.

See also SearchFilters.UnmarshalJSON.

func (SearchFilters) ProtoMessage

func (f SearchFilters) ProtoMessage() []*protoobject.SearchFilter

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

See also SearchFilters.FromProtoMessage.

func (*SearchFilters) UnmarshalJSON

func (f *SearchFilters) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes SearchFilters from protobuf JSON format.

See also SearchFilters.MarshalJSON.

type SearchMatchType

type SearchMatchType int32

SearchMatchType indicates match operation on specified header.

const (
	MatchUnspecified SearchMatchType = iota
	MatchStringEqual
	MatchStringNotEqual
	MatchNotPresent
	MatchCommonPrefix
	MatchNumGT
	MatchNumGE
	MatchNumLT
	MatchNumLE
)

func (*SearchMatchType) DecodeString

func (m *SearchMatchType) DecodeString(s string) bool

DecodeString parses SearchMatchType from a string representation. It is a reverse action to SearchMatchType.String.

Returns true if s was parsed successfully.

func (SearchMatchType) String

func (m SearchMatchType) String() string

String implements fmt.Stringer with the following string mapping:

All other values are base-10 integers.

The mapping is consistent and resilient to lib updates. At the same time, please note that this is not a NeoFS protocol format.

String is reverse to SearchMatchType.DecodeString.

type SplitID

type SplitID struct {
	// contains filtered or unexported fields
}

SplitID is a UUIDv4 used as attribute in split objects.

func NewSplitID

func NewSplitID() *SplitID

NewSplitID returns UUID representation of splitID attribute.

Defaults:

  • id: random UUID.

func NewSplitIDFromV2

func NewSplitIDFromV2(v []byte) *SplitID

NewSplitIDFromV2 returns parsed UUID from bytes. If v is invalid UUIDv4 byte sequence, then function returns nil.

Nil converts to nil.

func (*SplitID) Parse

func (id *SplitID) Parse(s string) (err error)

Parse converts UUIDv4 string representation into SplitID.

func (*SplitID) SetUUID

func (id *SplitID) SetUUID(v uuid.UUID)

SetUUID sets pre created UUID structure as SplitID.

func (*SplitID) String

func (id *SplitID) String() string

String returns UUIDv4 string representation of SplitID.

func (*SplitID) ToV2

func (id *SplitID) ToV2() []byte

ToV2 converts SplitID to a representation of SplitID in neofs-api v2.

Nil SplitID converts to nil.

type SplitInfo

type SplitInfo struct {
	// contains filtered or unexported fields
}

SplitInfo is an SDK representation of object.SplitInfo.

func NewSplitInfo

func NewSplitInfo() *SplitInfo

NewSplitInfo creates and initializes blank SplitInfo.

Defaults:

  • splitID: nil;
  • lastPart nil;
  • link: nil.

func (*SplitInfo) FromProtoMessage

func (s *SplitInfo) FromProtoMessage(m *protoobject.SplitInfo) error

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

See also SplitInfo.ProtoMessage.

func (SplitInfo) GetFirstPart

func (s SplitInfo) GetFirstPart() oid.ID

GetFirstPart returns the first part of the split chain. Zero means unset ID.

See also SplitInfo.SetFirstPart.

func (SplitInfo) GetLastPart

func (s SplitInfo) GetLastPart() oid.ID

GetLastPart returns last object ID, can be used to retrieve original object. Zero return means unset ID.

See also SplitInfo.SetLastPart.

func (s SplitInfo) GetLink() oid.ID

GetLink returns a linker object ID. Zero return means unset ID.

See also SplitInfo.SetLink.

func (SplitInfo) Marshal

func (s SplitInfo) Marshal() []byte

Marshal marshals SplitInfo into a protobuf binary form.

See also SplitInfo.Unmarshal.

func (SplitInfo) MarshalJSON

func (s SplitInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

See also SplitInfo.UnmarshalJSON.

func (SplitInfo) ProtoMessage

func (s SplitInfo) ProtoMessage() *protoobject.SplitInfo

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

See also SplitInfo.FromProtoMessage.

func (*SplitInfo) SetFirstPart

func (s *SplitInfo) SetFirstPart(v oid.ID)

SetFirstPart sets the first part of the split chain.

See also SplitInfo.GetFirstPart.

func (*SplitInfo) SetLastPart

func (s *SplitInfo) SetLastPart(v oid.ID)

SetLastPart sets the last object ID.

See also SplitInfo.GetLastPart.

func (s *SplitInfo) SetLink(v oid.ID)

SetLink sets linker object ID.

See also SplitInfo.GetLink.

func (*SplitInfo) SetSplitID

func (s *SplitInfo) SetSplitID(v *SplitID)

SetSplitID sets split ID in object ID. It resets split ID if nil passed.

See also SplitInfo.SplitID.

DEPRECATED.SplitInfo.SetFirstPart usage is required for the _new_ split objects, it serves as chain identification.

func (SplitInfo) SplitID

func (s SplitInfo) SplitID() *SplitID

SplitID returns SplitID if it has been set. New objects may miss it, use SplitInfo.GetFirstPart as a split chain identifier.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

See also SplitInfo.SetSplitID.

func (*SplitInfo) Unmarshal

func (s *SplitInfo) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of SplitInfo.

See also SplitInfo.Marshal.

func (*SplitInfo) UnmarshalJSON

func (s *SplitInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

See also SplitInfo.MarshalJSON.

type SplitInfoError

type SplitInfoError struct {
	// contains filtered or unexported fields
}

SplitInfoError is a special error that means that the original object is a large one (split into a number of smaller objects).

func NewSplitInfoError

func NewSplitInfoError(v *SplitInfo) *SplitInfoError

NewSplitInfoError is a constructor for SplitInfoError.

func (*SplitInfoError) Error

func (s *SplitInfoError) Error() string

Error implements the error interface.

func (*SplitInfoError) SplitInfo

func (s *SplitInfoError) SplitInfo() *SplitInfo

SplitInfo returns SplitInfo data.

type Tombstone

type Tombstone struct {
	// contains filtered or unexported fields
}

Tombstone represents object tombstone structure.

DEPRECATED: use Object.AssociateDeleted instead, deleting exactly one object per Tombstone.

func NewTombstone

func NewTombstone() *Tombstone

NewTombstone creates and initializes blank Tombstone.

Defaults:

  • exp: 0;
  • splitID: nil;
  • members: nil.

func (Tombstone) ExpirationEpoch

func (t Tombstone) ExpirationEpoch() uint64

ExpirationEpoch returns the last NeoFS epoch number of the tombstone lifetime.

See also Tombstone.SetExpirationEpoch.

func (*Tombstone) FromProtoMessage

func (t *Tombstone) FromProtoMessage(m *prototombstone.Tombstone) error

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

See also Tombstone.ProtoMessage.

func (Tombstone) Marshal

func (t Tombstone) Marshal() []byte

Marshal marshals Tombstone into a protobuf binary form.

See also Tombstone.Unmarshal.

func (Tombstone) MarshalJSON

func (t Tombstone) MarshalJSON() ([]byte, error)

MarshalJSON encodes Tombstone to protobuf JSON format.

See also Tombstone.UnmarshalJSON.

func (Tombstone) Members

func (t Tombstone) Members() []oid.ID

Members returns list of objects to be deleted.

See also Tombstone.SetMembers.

func (Tombstone) ProtoMessage

func (t Tombstone) ProtoMessage() *prototombstone.Tombstone

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

See also Tombstone.FromProtoMessage.

func (*Tombstone) SetExpirationEpoch

func (t *Tombstone) SetExpirationEpoch(v uint64)

SetExpirationEpoch sets the last NeoFS epoch number of the tombstone lifetime.

See also Tombstone.ExpirationEpoch.

func (*Tombstone) SetMembers

func (t *Tombstone) SetMembers(v []oid.ID)

SetMembers sets list of objects to be deleted.

See also Tombstone.Members.

func (*Tombstone) SetSplitID

func (t *Tombstone) SetSplitID(v *SplitID)

SetSplitID sets identifier of object split hierarchy.

See also Tombstone.SplitID.

func (Tombstone) SplitID

func (t Tombstone) SplitID() *SplitID

SplitID returns identifier of object split hierarchy.

The value returned shares memory with the structure itself, so changing it can lead to data corruption. Make a copy if you need to change it.

See also Tombstone.SetSplitID.

func (*Tombstone) Unmarshal

func (t *Tombstone) Unmarshal(data []byte) error

Unmarshal unmarshals protobuf binary representation of Tombstone.

See also Tombstone.Marshal.

func (*Tombstone) UnmarshalJSON

func (t *Tombstone) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Tombstone from protobuf JSON format.

See also Tombstone.MarshalJSON.

type Type

type Type int32

Type is an enumerator for possible object types.

const (
	TypeRegular Type = iota
	TypeTombstone
	// Deprecated: storage groups and audit are obsolete since API 2.18.
	TypeStorageGroup
	TypeLock
	TypeLink
)

func (*Type) DecodeString

func (t *Type) DecodeString(s string) bool

DecodeString parses Type from a string representation. It is a reverse action to Type.String.

Returns true if s was parsed successfully.

func (Type) String

func (t Type) String() string

String implements fmt.Stringer with the following string mapping:

All other values are base-10 integers.

The mapping is consistent and resilient to lib updates. At the same time, please note that this is not a NeoFS protocol format.

String is reverse to Type.DecodeString.

Directories

Path Synopsis
id
Package oid provides primitives to work with object identification in NeoFS.
Package oid provides primitives to work with object identification in NeoFS.
test
Package oidtest provides functions for convenient testing of oid package API.
Package oidtest provides functions for convenient testing of oid package API.
Package relations provides feature to process inner object structure.
Package relations provides feature to process inner object structure.
Package slicer provides raw data slicing into NeoFS objects.
Package slicer provides raw data slicing into NeoFS objects.

Jump to

Keyboard shortcuts

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