subnetid

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZero

func IsZero(id ID) bool

IsZero returns true iff the ID refers to zero subnet.

func MakeZero

func MakeZero(id *ID)

MakeZero makes ID to refer to zero subnet. Arg must not be nil (it is already zero).

Makes no sense to call on zero value (e.g. declared using var).

Types

type ID

type ID refs.SubnetID

ID represents NeoFS subnet identifier.

The type is compatible with the corresponding message from NeoFS API V2 protocol.

Zero value and nil pointer is equivalent to zero subnet ID.

func (*ID) Equals

func (x *ID) Equals(x2 *ID) bool

Equals returns true iff both instances identify the same subnet.

Method is NPE-safe: nil pointer equals to pointer to zero value.

func (*ID) FromV2

func (x *ID) FromV2(msg refs.SubnetID)

FromV2 initializes ID from refs.SubnetID message structure. Must not be called on nil.

Note: nil refs.SubnetID corresponds to zero ID value or nil pointer to it.

func (*ID) Marshal

func (x *ID) Marshal() ([]byte, error)

Marshal encodes ID into a binary format of NeoFS API V2 protocol (Protocol Buffers with direct field order).

func (*ID) MarshalText

func (x *ID) MarshalText() ([]byte, error)

MarshalText encodes ID into text format according to particular NeoFS API protocol. Supported versions:

  • V2 (see refs.SubnetID type).

Implements encoding.TextMarshaler.

func (*ID) SetNumber

func (x *ID) SetNumber(num uint32)

SetNumber sets ID value in uint32 format. Must not be called on nil. By default, number is 0 which refers to zero subnet.

func (*ID) String

func (x *ID) String() string

String returns string representation of ID using MarshalText. Returns string with message on error.

Implements fmt.Stringer.

func (*ID) Unmarshal

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

Unmarshal decodes ID from NeoFS API V2 binary format (see Marshal). Must not be called on nil.

Note: empty data corresponds to zero ID value or nil pointer to it.

func (*ID) UnmarshalText

func (x *ID) UnmarshalText(text []byte) error

UnmarshalText decodes ID from the text according to particular NeoFS API protocol. Must not be called on nil. Supported versions:

  • V2 (see refs.SubnetID type).

Implements encoding.TextUnmarshaler.

func (ID) WriteToV2

func (x ID) WriteToV2(msg *refs.SubnetID)

WriteToV2 writes ID to refs.SubnetID message structure. The message must not be nil.

Note: nil ID corresponds to zero refs.SubnetID value or nil pointer to it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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