Documentation ¶
Index ¶
- Constants
- Variables
- type Empty
- type Identifier
- func (t Identifier) Alias() (alias string)
- func (t Identifier) Base58() (base58Encoded string)
- func (t Identifier) Bytes() []byte
- func (t *Identifier) Decode(data []byte) (consumed int, err error)
- func (t Identifier) Encode() (serialized []byte, err error)
- func (t *Identifier) FromBase58(base58String string) (err error)
- func (t *Identifier) FromRandomness() (err error)
- func (t Identifier) RegisterAlias(alias string)
- func (t Identifier) String() (humanReadable string)
- func (t Identifier) UnregisterAlias()
Constants ¶
const IdentifierLength = 32
IdentifierLength contains the byte length of a serialized Identifier.
Variables ¶
var ( // ErrBase58DecodeFailed is returned if a base58 encoded string can not be decoded. ErrBase58DecodeFailed = errors.New("failed to decode base58 encoded string") )
var Void = Empty{}
Functions ¶
This section is empty.
Types ¶
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.