object

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilHeader = errors.New("object header is nil")

ErrNilHeader is returned by functions that expect a non-nil Header pointer, but received nil.

View Source
var ErrNilObject = errors.New("object is nil")

ErrNilObject is returned by functions that expect a non-nil Object pointer, but received nil.

Functions

func CopyPayload

func CopyPayload(o *Object) []byte

CopyPayload returns the copy of object payload.

Changing the result is safe and does not affect the object.

CopyPayload returns nil if object is nil.

func SetExtendedHeadersCopy

func SetExtendedHeadersCopy(h *Header, hs []ExtendedHeader)

SetExtendedHeadersCopy copies extended headers and sets the copy as the object extended headers.

Subsequent changing the source slice is safe and does not affect the header.

SetExtendedHeadersCopy does nothing if Header is nil.

func SetPayloadCopy

func SetPayloadCopy(o *Object, payload []byte)

SetPayloadCopy copies slice bytes and sets the copy as object payload.

Subsequent changing the source slice is safe and does not affect the object.

SetPayloadCopy does nothing if object is nil.

func TypeToUint32

func TypeToUint32(v ExtendedHeaderType) uint32

TypeToUint32 converts Epoch value to builtin uint32.

Try to avoid direct cast for better portability.

func TypesEQ

func TypesEQ(t1, t2 ExtendedHeaderType) bool

TypesEQ reports whether t1 and t2 are the same ExtendedHeaderType.

Function defines the relation of equality between two ExtendedHeaderType. Try to avoid comparison through "==" operator for better portability.

func TypesGT

func TypesGT(t1, t2 ExtendedHeaderType) bool

TypesGT reports whether t1 ExtendedHeaderType is greater than t2.

Function defines the "greater than" relation between two ExtendedHeaderType. Try to avoid comparison through ">" operator for better portability.

func TypesLT

func TypesLT(t1, t2 ExtendedHeaderType) bool

TypesLT reports whether t1 ExtendedHeaderType is less than t2.

Function defines the "less than" relation between two ExtendedHeaderType. Try to avoid comparison through "<" operator for better portability.

Types

type Address

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

Address represents NeoFS Object address. Acts as a reference to the object.

func AddressFromObject

func AddressFromObject(o *Object) *Address

AddressFromObject returns an address based on the object's header.

Returns nil on nil object.

func (Address) CID

func (a Address) CID() CID

CID return the identifier of the container that the object belongs to.

func (Address) ID

func (a Address) ID() ID

ID returns the unique identifier of the object in container.

func (*Address) SetCID

func (a *Address) SetCID(v CID)

SetCID sets the identifier of the container that the object belongs to.

func (*Address) SetID

func (a *Address) SetID(v ID)

SetID sets the unique identifier of the object in container.

type CID

type CID = container.ID

CID represents the container identifier.

It is a type alias of github.com/nspcc-dev/neofs-node/pkg/core/container.ID.

type Epoch

type Epoch = epoch.Epoch

Epoch represents the NeoFS epoch number.

It is a type alias of github.com/nspcc-dev/neofs-node/pkg/core/netmap/epoch.Epoch.

type ExtendedHeader

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

ExtendedHeader represents the extended header of NeoFS object.

func CopyExtendedHeaders

func CopyExtendedHeaders(h *Header) []ExtendedHeader

CopyExtendedHeaders returns the copy of extended headers.

Changing the result is safe and does not affect the header.

Returns nil if header is nil.

func (*ExtendedHeader) SetType

func (h *ExtendedHeader) SetType(v ExtendedHeaderType)

SetType sets the extended header type.

func (*ExtendedHeader) SetValue

func (h *ExtendedHeader) SetValue(v interface{})

SetValue sets the extended header value.

Caller must take into account that each type of header usually has a limited set of expected value types.

In the case of a reference type, the value is set by reference, so source value mutations affect header state. Therefore, callers must first copy the source value before changing manipulations.

func (ExtendedHeader) Type

Type returns the extended header type.

func (ExtendedHeader) Value

func (h ExtendedHeader) Value() interface{}

Value returns the extended header value.

In the case of a reference type, the value is returned by reference, so value mutations affect header state. Therefore, callers must first copy the value before changing manipulations.

type ExtendedHeaderType

type ExtendedHeaderType uint32

ExtendedHeaderType represents the enumeration of extended header types of the NeoFS object.

func TypeFromUint32

func TypeFromUint32(v uint32) ExtendedHeaderType

TypeFromUint32 converts builtin uint32 value to Epoch.

Try to avoid direct cast for better portability.

type Header struct {
	// SystemHeader is an obligatory part of any object header.
	// It is used to set the identity and basic parameters of
	// the object.
	//
	// Header must inherit all the methods of SystemHeader,
	// so the SystemHeader is embedded in Header.
	SystemHeader
	// contains filtered or unexported fields
}

Header represents NeoFS object header.

func (*Header) ExtendedHeaders

func (h *Header) ExtendedHeaders() []ExtendedHeader

ExtendedHeaders returns the extended headers of header.

Changing the result is unsafe and affects the header. In order to prevent state mutations, use CopyExtendedHeaders.

func (*Header) SetExtendedHeaders

func (h *Header) SetExtendedHeaders(v []ExtendedHeader)

SetExtendedHeaders sets the extended headers of the header.

Subsequent changing the source slice is unsafe and affects the header. In order to prevent state mutations, use SetExtendedHeadersCopy.

type ID

type ID = refs.ObjectID

ID represents the object identifier.

It is a type alias of github.com/nspcc-dev/neofs-api-go/refs.ObjectID. FIXME: object ID should be defined in core package.

type Object

type Object struct {
	// Header is an obligatory part of any object.
	// It is used to carry any additional information
	// besides payload.
	//
	// Object must inherit all the methods of Header,
	// so the Header is embedded in Object.
	Header
	// contains filtered or unexported fields
}

Object represents NeoFS Object.

func (*Object) Payload

func (o *Object) Payload() []byte

Payload returns payload bytes of the object.

Changing the result is unsafe and affects the object. In order to prevent state mutations, use CopyPayload.

func (*Object) SetPayload

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

SetPayload sets objecyt payload bytes.

Subsequent changing the source slice is unsafe and affects the object. In order to prevent state mutations, use SetPayloadCopy.

type OwnerID

type OwnerID = container.OwnerID

OwnerID represents the container owner identifier.

It is a type alias of github.com/nspcc-dev/neofs-node/pkg/core/container.OwnerID.

type SystemHeader

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

SystemHeader represents the system header of NeoFS Object.

func (*SystemHeader) CID

func (s *SystemHeader) CID() CID

CID returns the container identifier to which the object belongs.

func (*SystemHeader) CreationEpoch

func (s *SystemHeader) CreationEpoch() Epoch

CreationEpoch returns the epoch number in which the object was created.

func (*SystemHeader) ID

func (s *SystemHeader) ID() ID

ID returns the object identifier.

func (*SystemHeader) OwnerID

func (s *SystemHeader) OwnerID() OwnerID

OwnerID returns the object owner identifier.

func (*SystemHeader) PayloadLength

func (s *SystemHeader) PayloadLength() uint64

PayloadLength returns the length of the object payload bytes.

func (*SystemHeader) SetCID

func (s *SystemHeader) SetCID(v CID)

SetCID sets the container identifier to which the object belongs.

func (*SystemHeader) SetCreationEpoch

func (s *SystemHeader) SetCreationEpoch(v Epoch)

SetCreationEpoch sets the epoch number in which the object was created.

func (*SystemHeader) SetID

func (s *SystemHeader) SetID(v ID)

SetID sets the object identifier.

func (*SystemHeader) SetOwnerID

func (s *SystemHeader) SetOwnerID(v OwnerID)

SetOwnerID sets the object owner identifier.

func (*SystemHeader) SetPayloadLength

func (s *SystemHeader) SetPayloadLength(v uint64)

SetPayloadLength sets the length of the object payload bytes.

func (*SystemHeader) SetVersion

func (s *SystemHeader) SetVersion(v uint64)

SetVersion sets the object version number.

func (*SystemHeader) Version

func (s *SystemHeader) Version() uint64

Version returns the object version number.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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