types

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const IdentifierLength = 32

IdentifierLength contains the byte length of a serialized Identifier.

Variables

View Source
var (
	// ErrBase58DecodeFailed is returned if a base58 encoded string can not be decoded.
	ErrBase58DecodeFailed = errors.New("failed to decode base58 encoded string")
)
View Source
var Void = Empty{}

Functions

This section is empty.

Types

type Empty

type Empty struct{}

type Identifier

type Identifier [IdentifierLength]byte

Identifier is a 32 byte hash value that can be used to uniquely identify some blob of data.

func NewIdentifier

func NewIdentifier(data []byte) Identifier

NewIdentifier returns a new Identifier for the given data.

func (Identifier) Alias

func (t Identifier) Alias() (alias string)

Alias returns the human-readable alias of the Identifier (or the base58 encoded bytes of no alias was set).

func (Identifier) Base58

func (t Identifier) Base58() (base58Encoded string)

Base58 returns a base58 encoded version of the Identifier.

func (Identifier) Bytes

func (t Identifier) Bytes() []byte

Bytes returns the raw bytes of the Identifier.

func (*Identifier) Decode

func (t *Identifier) Decode(data []byte) (consumed int, err error)

Decode decodes the Identifier from a sequence of bytes.

func (Identifier) Encode

func (t Identifier) Encode() (serialized []byte, err error)

Encode returns a serialized version of the Identifier.

func (*Identifier) FromBase58

func (t *Identifier) FromBase58(base58String string) (err error)

FromBase58 un-serializes an Identifier from a base58 encoded string.

func (*Identifier) FromRandomness

func (t *Identifier) FromRandomness() (err error)

FromRandomness generates a random Identifier.

func (Identifier) RegisterAlias

func (t Identifier) RegisterAlias(alias string)

RegisterAlias allows to register a human-readable alias for the Identifier which will be used as a replacement for the String method.

func (Identifier) String

func (t Identifier) String() (humanReadable string)

String returns a human-readable version of the Identifier.

func (Identifier) UnregisterAlias

func (t Identifier) UnregisterAlias()

UnregisterAlias allows to unregister a previously registered alias.

Jump to

Keyboard shortcuts

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