Documentation
¶
Overview ¶
Package lazybytes is a way to treat byte data as serialized arrays or, recursively, as trees of byte slices It is used for fast, safe and uniform serialization/deserialization in 'lazy' way: the bytes are only deserialized when there's a need to access element of the array or a tree The read-only lazy array and tree are thread safe. Non-read only are not thread safe It is used for the (de)serialization of Proxima transactions into the tree form, where every element (a byte slice) can be accessed with a path of indices (bytes)
Index ¶
- Constants
- type Array
- func ArrayFromBytesReadOnly(data []byte, maxNumElements ...int) *Array
- func EmptyArray(maxNumElements ...int) *Array
- func MakeArrayFromDataReadOnly(element ...[]byte) *Array
- func MakeArrayReadOnly(element ...any) *Array
- func ParseArrayFromBytesReadOnly(data []byte, maxNumElements ...int) (*Array, error)
- func (a *Array) AsTree() *Tree
- func (a *Array) At(idx int) []byte
- func (a *Array) AtSafe(idx int) ([]byte, error)
- func (a *Array) Bytes() []byte
- func (a *Array) ForEach(fun func(i int, data []byte) bool)
- func (a *Array) NumElements() int
- func (a *Array) Parsed() [][]byte
- func (a *Array) ParsedString() string
- func (a *Array) Push(data []byte) int
- func (a *Array) PutAtIdx(idx byte, data []byte)
- func (a *Array) PutAtIdxWithPadding(idx byte, data []byte)
- func (a *Array) SetData(data []byte)
- func (a *Array) SetEmptyArray()
- func (a *Array) SetReadOnly(ro bool) *Array
- type Tree
- func (st *Tree) Bytes() []byte
- func (st *Tree) BytesAtPath(path TreePath) []byte
- func (st *Tree) ForEach(fun func(i byte, data []byte) bool, path TreePath)
- func (st *Tree) ForEachIndex(fun func(i byte) bool, path TreePath)
- func (st *Tree) NumElements(path TreePath) int
- func (st *Tree) Subtree(path TreePath) *Tree
- type TreePath
Constants ¶
const MaxElementsLazyTree = 256
MaxElementsLazyTree each node of the tree can have maximum 256 elements
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
func ArrayFromBytesReadOnly ¶
func MakeArrayReadOnly ¶
func (*Array) NumElements ¶
func (*Array) ParsedString ¶
func (*Array) PutAtIdxWithPadding ¶
PutAtIdxWithPadding puts data at index, pads elements with nils if necessary
func (*Array) SetEmptyArray ¶
func (a *Array) SetEmptyArray()
func (*Array) SetReadOnly ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree is a read only interface to Array, which is interpreted as a tree
func TreeFromBytesReadOnly ¶
func TreeFromTreesReadOnly ¶
func (*Tree) BytesAtPath ¶
BytesAtPath returns serialized for of the element at globalpath
func (*Tree) NumElements ¶
NumElements returns number of elements of the Array at the end of globalpath