object

package
v1.0.0-rc.11 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 64

Documentation

Index

Examples

Constants

View Source
const (
	FilterVersion                = v2object.FilterHeaderVersion
	FilterID                     = v2object.FilterHeaderObjectID
	FilterContainerID            = v2object.FilterHeaderContainerID
	FilterOwnerID                = v2object.FilterHeaderOwnerID
	FilterPayloadChecksum        = v2object.FilterHeaderPayloadHash
	FilterType                   = v2object.FilterHeaderObjectType
	FilterPayloadHomomorphicHash = v2object.FilterHeaderHomomorphicHash
	FilterParentID               = v2object.FilterHeaderParent
	FilterSplitID                = v2object.FilterHeaderSplitID
	FilterCreationEpoch          = v2object.FilterHeaderCreationEpoch
	FilterPayloadSize            = v2object.FilterHeaderPayloadLength
)

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 = v2object.FilterPropertyRoot
	// 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 = v2object.FilterPropertyPhy
)

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 (
	// 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 = object.SysAttributeExpEpoch
)

Various system attributes.

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 object.Attribute

Attribute represents v2-compatible object attribute.

func NewAttribute

func NewAttribute() *Attribute

NewAttribute creates and initializes blank Attribute.

Works similar as NewAttributeFromV2(new(Attribute)).

Defaults:

  • key: "";
  • value: "".

func NewAttributeFromV2

func NewAttributeFromV2(aV2 *object.Attribute) *Attribute

NewAttributeFromV2 wraps v2 object.Attribute message to Attribute.

Nil object.Attribute converts to nil.

func (*Attribute) Key

func (a *Attribute) Key() string

Key returns key to the object attribute.

func (*Attribute) Marshal

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

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) ToV2

func (a *Attribute) ToV2() *object.Attribute

ToV2 converts Attribute to v2 object.Attribute message.

Nil Attribute converts to nil.

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 (*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 Lock

type Lock v2object.Lock

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.

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 NotificationInfo

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

NotificationInfo groups information about object notification that can be written to object.

Topic is an optional field.

func (NotificationInfo) Epoch

func (n NotificationInfo) Epoch() uint64

Epoch returns object notification tick epoch.

See also NotificationInfo.SetEpoch.

func (*NotificationInfo) SetEpoch

func (n *NotificationInfo) SetEpoch(epoch uint64)

SetEpoch sets object notification tick epoch.

See also NotificationInfo.Epoch.

func (*NotificationInfo) SetTopic

func (n *NotificationInfo) SetTopic(topic string)

SetTopic sets optional object notification topic.

See also NotificationInfo.Topic.

func (NotificationInfo) Topic

func (n NotificationInfo) Topic() string

Topic return optional object notification topic.

See also NotificationInfo.SetTopic.

type Object

type Object object.Object

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

Instance can be created depending on scenario:

  • Object.InitCreation (an object to be placed in container);
  • New (blank instance, usually needed for decoding);
  • NewFromV2 (when working under NeoFS API V2 protocol).

func New

func New() *Object

New creates and initializes blank Object.

Works similar as NewFromV2(new(Object)).

func NewFromV2

func NewFromV2(oV2 *object.Object) *Object

NewFromV2 wraps v2 object.Object message to Object.

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) ContainerID

func (o *Object) ContainerID() (v cid.ID, isSet bool)

ContainerID returns identifier of the related container.

See also Object.SetContainerID.

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) HasParent

func (o *Object) HasParent() bool

HasParent checks if parent (split ID) is present.

func (*Object) ID

func (o *Object) ID() (v oid.ID, isSet bool)

ID returns object identifier.

See also Object.SetID.

func (*Object) InitCreation

func (o *Object) InitCreation(rf RequiredFields)

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

func (*Object) InitRelations

func (o *Object) InitRelations()

InitRelations initializes relation field.

func (*Object) Marshal

func (o *Object) Marshal() ([]byte, error)

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) NotificationInfo

func (o *Object) NotificationInfo() (*NotificationInfo, error)

NotificationInfo returns notification info read from the object structure. Returns any error that appeared during notification information parsing.

See also Object.SetNotification.

func (*Object) OwnerID

func (o *Object) OwnerID() *user.ID

OwnerID returns identifier of the object owner.

See also Object.SetOwnerID.

func (*Object) Parent

func (o *Object) Parent() *Object

Parent returns parent object w/o payload.

See also Object.SetParent.

func (*Object) ParentID

func (o *Object) ParentID() (v oid.ID, isSet bool)

ParentID returns identifier of the parent object.

See also Object.SetParentID.

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) PreviousID

func (o *Object) PreviousID() (v oid.ID, isSet bool)

PreviousID returns identifier of the previous sibling object.

See also Object.SetPreviousID.

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.PreviousID.

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.ContainerID.

func (*Object) SetCreationEpoch

func (o *Object) SetCreationEpoch(v uint64)

SetCreationEpoch sets epoch number in which object was created.

See also Object.CreationEpoch.

func (*Object) SetID

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

SetID sets object identifier.

See also Object.ID.

func (*Object) SetIDWithSignature

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

SetIDWithSignature sets object identifier and signature.

func (*Object) SetNotification

func (o *Object) SetNotification(ni NotificationInfo)

SetNotification writes NotificationInfo to the object structure.

See also Object.NotificationInfo.

func (*Object) SetOwnerID

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

SetOwnerID sets identifier of the object owner.

See also Object.OwnerID.

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.ParentID.

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.PreviousID.

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) ToV2

func (o *Object) ToV2() *object.Object

ToV2 converts Object to v2 object.Object message.

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) 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.

See also Object.SetVersion.

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 object.Range

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 NewRangeFromV2

func NewRangeFromV2(rV2 *object.Range) *Range

NewRangeFromV2 wraps v2 object.Range message to Range.

Nil object.Range converts to nil.

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.

func (*Range) ToV2

func (r *Range) ToV2() *object.Range

ToV2 converts Range to v2 object.Range message.

Nil Range converts to nil.

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.

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 NewSearchFiltersFromV2

func NewSearchFiltersFromV2(v2 []v2object.SearchFilter) SearchFilters

NewSearchFiltersFromV2 converts slice of v2object.SearchFilter to SearchFilters.

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.

func (*SearchFilters) AddHomomorphicHashFilter

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

AddHomomorphicHashFilter adds filter by homomorphic hash.

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")

	var v [tz.Size]byte
	copy(v[:], hash[:tz.Size])

	var cs checksum.Checksum
	cs.SetTillichZemor(v)

	fmt.Println(hex.EncodeToString(cs.Value()))
}
Output:

7e302ebb3937e810feb501965580c746048db99cebd095c3ce27022407408bf904dde8d9aa8085d2cf7202345341cc947fa9d722c6b6699760d307f653815d0c

func (*SearchFilters) AddNotificationEpochFilter

func (f *SearchFilters) AddNotificationEpochFilter(epoch uint64)

AddNotificationEpochFilter adds a filter by epoch. This epoch is not about expiration, but about notification production.

func (*SearchFilters) AddObjectContainerIDFilter

func (f *SearchFilters) AddObjectContainerIDFilter(m SearchMatchType, id cid.ID)

AddObjectContainerIDFilter adds a filter by container id.

func (*SearchFilters) AddObjectIDFilter

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

AddObjectIDFilter adds filter by object identifier.

func (*SearchFilters) AddObjectOwnerIDFilter

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

AddObjectOwnerIDFilter adds a filter by object owner id.

func (*SearchFilters) AddObjectVersionFilter

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

AddObjectVersionFilter adds a filter by version.

func (*SearchFilters) AddParentIDFilter

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

AddParentIDFilter adds filter by parent identifier.

func (*SearchFilters) AddPayloadHashFilter

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

AddPayloadHashFilter adds filter by payload hash.

Example
package main

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

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

func main() {
	hash, _ := hex.DecodeString("66842cfea090b1d906b52400fae49d86df078c0670f2bdd059ba289ebe24a498")

	var v [sha256.Size]byte
	copy(v[:], hash[:sha256.Size])

	var cs checksum.Checksum
	cs.SetSHA256(v)

	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.

func (*SearchFilters) AddTypeFilter

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

AddTypeFilter adds filter by object type.

func (*SearchFilters) MarshalJSON

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

MarshalJSON encodes SearchFilters to protobuf JSON format.

See also SearchFilters.UnmarshalJSON.

func (SearchFilters) ToV2

func (f SearchFilters) ToV2() []v2object.SearchFilter

ToV2 converts SearchFilters to v2object.SearchFilter slice.

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 uint32

SearchMatchType indicates match operation on specified header.

const (
	MatchUnknown SearchMatchType = iota
	MatchStringEqual
	MatchStringNotEqual
	MatchNotPresent
	MatchCommonPrefix
)

func SearchMatchFromV2

func SearchMatchFromV2(t v2object.MatchType) (m SearchMatchType)

SearchMatchFromV2 converts v2 v2object.MatchType to SearchMatchType enum value.

func (*SearchMatchType) DecodeString

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

DecodeString parses SearchMatchType from a string representation. It is a reverse action to EncodeToString().

Returns true if s was parsed successfully.

func (SearchMatchType) EncodeToString

func (m SearchMatchType) EncodeToString() string

EncodeToString returns string representation of SearchMatchType.

String mapping:

func (SearchMatchType) String

func (m SearchMatchType) 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 (SearchMatchType) ToV2

ToV2 converts SearchMatchType to v2 v2object.MatchType enum value.

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 object.SplitInfo

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 NewSplitInfoFromV2

func NewSplitInfoFromV2(v2 *object.SplitInfo) *SplitInfo

NewSplitInfoFromV2 wraps v2 object.SplitInfo message to SplitInfo.

Nil object.SplitInfo converts to nil.

func (SplitInfo) LastPart

func (s SplitInfo) LastPart() (v oid.ID, isSet bool)

LastPart returns last object ID, can be used to retrieve original object. The second return value is a flag, indicating if the last part is present.

See also SplitInfo.SetLastPart.

func (s SplitInfo) Link() (v oid.ID, isSet bool)

Link returns a linker object ID. The second return value is a flag, indicating if the last part is present.

See also SplitInfo.SetLink.

func (*SplitInfo) Marshal

func (s *SplitInfo) Marshal() ([]byte, error)

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) SetLastPart

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

SetLastPart sets the last object ID.

See also SplitInfo.LastPart.

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

SetLink sets linker object ID.

See also SplitInfo.Link.

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.

func (*SplitInfo) SplitID

func (s *SplitInfo) SplitID() *SplitID

SplitID returns SplitID if it has been set.

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) ToV2

func (s *SplitInfo) ToV2() *object.SplitInfo

ToV2 converts SplitInfo to v2 object.SplitInfo message.

Nil SplitInfo converts to nil.

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 (*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 tombstone.Tombstone

Tombstone represents v2-compatible tombstone structure.

func NewTombstone

func NewTombstone() *Tombstone

NewTombstone creates and initializes blank Tombstone.

Defaults:

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

func NewTombstoneFromV2

func NewTombstoneFromV2(tV2 *tombstone.Tombstone) *Tombstone

NewTombstoneFromV2 wraps v2 tombstone.Tombstone message to Tombstone.

Nil tombstone.Tombstone converts to 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) Marshal

func (t *Tombstone) Marshal() ([]byte, error)

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) 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) ToV2

func (t *Tombstone) ToV2() *tombstone.Tombstone

ToV2 converts Tombstone to v2 tombstone.Tombstone message.

Nil Tombstone converts to nil.

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 (*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 object.Type

Type is an enumerator for possible object types.

const (
	TypeRegular Type = iota
	TypeTombstone
	TypeStorageGroup
	TypeLock
)

func TypeFromV2

func TypeFromV2(t object.Type) Type

TypeFromV2 converts v2 object.Type to Type.

func (*Type) DecodeString

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

DecodeString parses Type from a string representation. It is a reverse action to EncodeToString().

Returns true if s was parsed successfully.

func (Type) EncodeToString

func (t Type) EncodeToString() string

EncodeToString returns string representation of Type.

String mapping:

func (Type) String

func (t Type) 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 Type.EncodeToString. String MUST NOT be used to encode ID into NeoFS protocol string.

func (Type) ToV2

func (t Type) ToV2() object.Type

ToV2 converts Type to v2 object.Type.

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