subnetid

package
v0.0.0-...-5e759bf Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Overview

Package subnetid provides primitives to work with subnet identification in FrostFS.

ID type is used for global subnet identity inside the FrostFS network.

Using package types in an application is recommended to potentially work with different protocol versions with which these types are compatible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZero

func IsZero(id ID) bool

IsZero compares id with zero subnet ID.

func MakeZero

func MakeZero(id *ID)

MakeZero makes ID to refer to zero subnet.

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

Types

type ID

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

ID represents unique identifier of the subnet in the FrostFS network.

ID is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/refs.SubnetID message. See ReadFromV2 / WriteToV2 methods.

Instances can be created using built-in var declaration. Zero value is equivalent to identifier of the zero subnet (whole FrostFS network).

func (*ID) DecodeString

func (x *ID) DecodeString(s string) error

DecodeString decodes string calculated using EncodeToString. Returns an error if s is malformed.

func (ID) EncodeToString

func (x ID) EncodeToString() string

EncodeToString encodes ID into FrostFS API protocol string (base10 encoding).

See also DecodeString.

func (ID) Equals

func (x ID) Equals(x2 ID) bool

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

func (x ID) Marshal() []byte

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

See also Unmarshal.

func (*ID) ReadFromV2

func (x *ID) ReadFromV2(msg refs.SubnetID) error

ReadFromV2 reads ID from the refs.SubnetID message. Checks if the message conforms to FrostFS API V2 protocol.

See also WriteToV2.

func (*ID) SetNumeric

func (x *ID) SetNumeric(num uint32)

SetNumeric sets ID value in numeric format. By default, number is 0 which refers to the zero subnet.

func (ID) String

func (x ID) 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 FrostFS protocol string.

func (*ID) Unmarshal

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

Unmarshal decodes binary ID calculated using Marshal. Returns an error describing a format violation.

func (ID) WriteToV2

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

WriteToV2 writes ID to refs.SubnetID message structure. The message MUST NOT be nil.

See also ReadFromV2.

Directories

Path Synopsis
Package subnetidtest provides functions for convenient testing of subnetid package API.
Package subnetidtest provides functions for convenient testing of subnetid package API.

Jump to

Keyboard shortcuts

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