cid

package
v0.0.0-...-afdc2d8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 51

Documentation

Overview

Package cid provides primitives to work with container identification in FrostFS.

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

This section is empty.

Types

type ID

type ID [sha256.Size]byte

ID represents FrostFS container identifier.

ID is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs.ContainerID message. See ReadFromV2 / WriteToV2 methods.

Instances can be created using built-in var declaration.

Note that direct typecast is not safe and may result in loss of compatibility:

_ = ID([32]byte) // not recommended

func (*ID) Decode

func (id *ID) Decode(src []byte) error

Decode decodes src bytes into ID.

Decode expects that src has 32 bytes length. If the input is malformed, Decode returns an error describing format violation. In this case ID remains unchanged.

Decode doesn't mutate src.

See also Encode.

func (*ID) DecodeString

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

DecodeString decodes string into ID according to FrostFS API protocol. Returns an error if s is malformed.

See also DecodeString.

func (ID) Encode

func (id ID) Encode(dst []byte)

Encode encodes ID into 32 bytes of dst. Panics if dst length is less than 32.

Zero ID is all zeros.

See also Decode.

func (ID) EncodeToString

func (id ID) EncodeToString() string

EncodeToString encodes ID into FrostFS API protocol string.

Zero ID is base58 encoding of 32 zeros.

See also DecodeString.

func (ID) Equals

func (id ID) Equals(id2 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) ReadFromV2

func (id *ID) ReadFromV2(m refs.ContainerID) error

ReadFromV2 reads ID from the refs.ContainerID message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.

See also WriteToV2.

func (*ID) SetSHA256

func (id *ID) SetSHA256(v [sha256.Size]byte)

SetSHA256 sets container identifier value to SHA256 checksum of container structure.

func (ID) String

func (id 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) WriteToV2

func (id ID) WriteToV2(m *refs.ContainerID)

WriteToV2 writes ID to the refs.ContainerID message. The message must not be nil.

See also ReadFromV2.

Directories

Path Synopsis
Package cidtest provides functions for convenient testing of cid package API.
Package cidtest provides functions for convenient testing of cid package API.

Jump to

Keyboard shortcuts

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