record

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const KeyHashLength = 32

Variables

This section is empty.

Functions

func DisableKeyNameTracking added in v1.1.1

func DisableKeyNameTracking()

func EnableKeyNameTracking added in v1.1.1

func EnableKeyNameTracking()

func ReadBinary

func ReadBinary[V any](v *V, read func(uint) (V, bool))

Types

type Key

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

A Key is the key for a record.

func KeyFromHash added in v1.2.10

func KeyFromHash(kh KeyHash) *Key

func NewKey added in v1.1.1

func NewKey(v ...any) *Key

func (*Key) Append

func (k *Key) Append(v ...any) *Key

Append creates a child key of this key.

func (*Key) AppendKey added in v1.1.1

func (k *Key) AppendKey(l *Key) *Key

AppendKey appends one key to another. AppendKey will panic if K is not empty and L starts with a precomputed KeyHash.

func (*Key) Compare added in v1.1.1

func (k *Key) Compare(l *Key) int

Compare compares two keys. Compare may panic if either key has an unexpected value type.

func (*Key) Copy

func (k *Key) Copy() *Key

Copy returns a copy of the key.

func (*Key) CopyAsInterface

func (k *Key) CopyAsInterface() any

CopyAsInterface implements encoding.BinaryValue.

func (*Key) Equal

func (k *Key) Equal(l *Key) bool

Equal checks if the two keys are equal.

func (*Key) Get added in v1.1.1

func (k *Key) Get(i int) any

func (*Key) Hash

func (k *Key) Hash() KeyHash

Hash converts the record key to a storage key.

func (*Key) Len added in v1.1.1

func (k *Key) Len() int

func (*Key) MarshalBinary

func (k *Key) MarshalBinary() ([]byte, error)

MarshalBinary marshals the key to bytes.

func (*Key) MarshalJSON

func (k *Key) MarshalJSON() ([]byte, error)

MarshalJSON marshals the key to JSON.

The key is marshaled as an list of single item objects where the key is the type code and the value is the value. For example:

[{"string": "Account"}, {"url": "foo.acme"}, {"string": "MainChain"}, {"string": "Element"}, {"int": 1}]

func (*Key) SliceI added in v1.1.1

func (k *Key) SliceI(i int) *Key

func (*Key) SliceJ added in v1.1.1

func (k *Key) SliceJ(j int) *Key

func (*Key) String

func (k *Key) String() string

String returns a human-readable string for the key.

func (*Key) Stringf added in v1.1.1

func (k *Key) Stringf(format string) string

func (*Key) UnmarshalBinary

func (k *Key) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals a key from bytes.

func (*Key) UnmarshalBinaryFrom

func (k *Key) UnmarshalBinaryFrom(rd io.Reader) error

UnmarshalBinaryFrom unmarshals a key from bytes.

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a key from JSON.

See Key.MarshalJSON for the format and an example.

type KeyHash added in v1.1.1

type KeyHash [KeyHashLength]byte

func (KeyHash) Append added in v1.1.1

func (k KeyHash) Append(key ...interface{}) KeyHash

func (KeyHash) MarshalJSON added in v1.1.1

func (k KeyHash) MarshalJSON() ([]byte, error)

MarshalJSON is implemented for JSON-based logging

func (KeyHash) String added in v1.1.1

func (k KeyHash) String() string

String hex encodes the key. If debugging is enabled, String looks up the original composite key.

Jump to

Keyboard shortcuts

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