view

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 10 Imported by: 42

Documentation

Index

Constants

View Source
const ByteType = Uint8Type

Alias to Uint8Type

View Source
const OffsetByteLength = 4

Variables

View Source
var BadLengthError = errors.New("scope is wrong")
View Source
var BasicViewNoSetBackingError = errors.New("basic views cannot set new backing")
View Source
var UnsupportedUintType = errors.New("unsupported uint type")

Functions

func AsBytes16

func AsBytes16(v View, err error) ([16]byte, error)

func AsBytes4

func AsBytes4(v View, err error) ([4]byte, error)

func AsBytes8

func AsBytes8(v View, err error) ([8]byte, error)

func AsRoot

func AsRoot(v View, err error) (Root, error)

func ByteBitIndex

func ByteBitIndex(v byte) (out uint64)

Get index of left-most 1 bit. 0 (incl.) to 8 (excl.)

func BytesIntoNodes

func BytesIntoNodes(contents []byte) ([]Node, error)

func SubtreeIntoBytes

func SubtreeIntoBytes(anchor Node, depth uint8, length uint64, dest []byte) error

Copy over the roots at the bottom of the subtree from left to right into dest (until dest is full)

Types

type BackedView

type BackedView struct {
	ViewBase
	Hook        BackingHook
	BackingNode Node
}

func (*BackedView) Backing

func (v *BackedView) Backing() Node

func (*BackedView) Copy

func (v *BackedView) Copy() (View, error)

func (*BackedView) Default

func (v *BackedView) Default(hook BackingHook) (View, error)

func (*BackedView) HashTreeRoot

func (v *BackedView) HashTreeRoot(h HashFn) Root

func (*BackedView) SetBacking

func (v *BackedView) SetBacking(b Node) error

type BackingHook

type BackingHook func(b Node) error

func (BackingHook) PropagateChangeMaybe

func (vh BackingHook) PropagateChangeMaybe(b Node) error

type BasicListTypeDef

type BasicListTypeDef struct {
	ElemType  BasicTypeDef
	ListLimit uint64
	ComplexTypeBase
}

func BasicListType

func BasicListType(elemType BasicTypeDef, limit uint64) *BasicListTypeDef

func (*BasicListTypeDef) BottomNodeLimit

func (td *BasicListTypeDef) BottomNodeLimit() uint64

func (*BasicListTypeDef) Default

func (td *BasicListTypeDef) Default(hook BackingHook) View

func (*BasicListTypeDef) DefaultNode

func (td *BasicListTypeDef) DefaultNode() Node

func (*BasicListTypeDef) Deserialize

func (td *BasicListTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*BasicListTypeDef) ElementType

func (td *BasicListTypeDef) ElementType() TypeDef

func (*BasicListTypeDef) ElementsPerBottomNode

func (td *BasicListTypeDef) ElementsPerBottomNode() uint64

func (*BasicListTypeDef) FromElements

func (td *BasicListTypeDef) FromElements(v ...BasicView) (*BasicListView, error)

func (*BasicListTypeDef) Limit

func (td *BasicListTypeDef) Limit() uint64

func (*BasicListTypeDef) New

func (td *BasicListTypeDef) New() *BasicListView

func (*BasicListTypeDef) String

func (td *BasicListTypeDef) String() string

func (*BasicListTypeDef) TranslateIndex

func (td *BasicListTypeDef) TranslateIndex(index uint64) (nodeIndex uint64, intraNodeIndex uint8)

func (*BasicListTypeDef) ViewFromBacking

func (td *BasicListTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type BasicListView

type BasicListView struct {
	SubtreeView
	*BasicListTypeDef
}

func AsBasicList

func AsBasicList(v View, err error) (*BasicListView, error)

func (*BasicListView) Append

func (tv *BasicListView) Append(view BasicView) error

func (*BasicListView) CheckIndex

func (tv *BasicListView) CheckIndex(i uint64) error

func (*BasicListView) Copy

func (tv *BasicListView) Copy() (View, error)

func (*BasicListView) Get

func (tv *BasicListView) Get(i uint64) (BasicView, error)

func (*BasicListView) Iter

func (tv *BasicListView) Iter() ElemIter

func (*BasicListView) Length

func (tv *BasicListView) Length() (uint64, error)

func (*BasicListView) Pop

func (tv *BasicListView) Pop() error

func (*BasicListView) ReadonlyIter

func (tv *BasicListView) ReadonlyIter() ElemIter

func (*BasicListView) Serialize

func (tv *BasicListView) Serialize(w *codec.EncodingWriter) error

func (*BasicListView) Set

func (tv *BasicListView) Set(i uint64, v BasicView) error

func (*BasicListView) ValueByteLength

func (tv *BasicListView) ValueByteLength() (uint64, error)

func (*BasicListView) ViewRoot

func (tv *BasicListView) ViewRoot(h HashFn) Root

type BasicTypeDef

type BasicTypeDef interface {
	TypeDef
	BasicViewFromBacking(node *Root, i uint8) (BasicView, error)
	PackViews(views []BasicView) ([]Node, error)
}

type BasicVectorTypeDef

type BasicVectorTypeDef struct {
	ElemType     BasicTypeDef
	VectorLength uint64
	ComplexTypeBase
}

func BasicVectorType

func BasicVectorType(elemType BasicTypeDef, length uint64) *BasicVectorTypeDef

func (*BasicVectorTypeDef) BottomNodeLength

func (td *BasicVectorTypeDef) BottomNodeLength() uint64

func (*BasicVectorTypeDef) Default

func (td *BasicVectorTypeDef) Default(hook BackingHook) View

func (*BasicVectorTypeDef) DefaultNode

func (td *BasicVectorTypeDef) DefaultNode() Node

func (*BasicVectorTypeDef) Deserialize

func (td *BasicVectorTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*BasicVectorTypeDef) ElementType

func (td *BasicVectorTypeDef) ElementType() TypeDef

func (*BasicVectorTypeDef) ElementsPerBottomNode

func (td *BasicVectorTypeDef) ElementsPerBottomNode() uint64

func (*BasicVectorTypeDef) FromElements

func (td *BasicVectorTypeDef) FromElements(v ...BasicView) (*BasicVectorView, error)

func (*BasicVectorTypeDef) Length

func (td *BasicVectorTypeDef) Length() uint64

func (*BasicVectorTypeDef) New

func (*BasicVectorTypeDef) String

func (td *BasicVectorTypeDef) String() string

func (*BasicVectorTypeDef) TranslateIndex

func (td *BasicVectorTypeDef) TranslateIndex(index uint64) (nodeIndex uint64, intraNodeIndex uint8)

func (*BasicVectorTypeDef) ViewFromBacking

func (td *BasicVectorTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type BasicVectorView

type BasicVectorView struct {
	SubtreeView
	*BasicVectorTypeDef
}

func AsBasicVector

func AsBasicVector(v View, err error) (*BasicVectorView, error)

func (*BasicVectorView) Copy

func (tv *BasicVectorView) Copy() (View, error)

func (*BasicVectorView) Get

func (tv *BasicVectorView) Get(i uint64) (BasicView, error)

func (*BasicVectorView) Iter

func (tv *BasicVectorView) Iter() ElemIter

func (*BasicVectorView) ReadonlyIter

func (tv *BasicVectorView) ReadonlyIter() ElemIter

func (*BasicVectorView) Serialize

func (tv *BasicVectorView) Serialize(w *codec.EncodingWriter) error

func (*BasicVectorView) Set

func (tv *BasicVectorView) Set(i uint64, v BasicView) error

func (*BasicVectorView) ValueByteLength

func (tv *BasicVectorView) ValueByteLength() (uint64, error)

type BasicView

type BasicView interface {
	View
	BackingFromBase(base *Root, i uint8) *Root
}

type BitIter

type BitIter interface {
	// Next gets the next element, ok is true if it actually exists.
	// An error may occur if data is missing or corrupt.
	Next() (elem bool, ok bool, err error)
}

type BitIterFn

type BitIterFn func() (elem bool, ok bool, err error)

func (BitIterFn) Next

func (f BitIterFn) Next() (elem bool, ok bool, err error)

type BitListTypeDef

type BitListTypeDef struct {
	BitLimit uint64
	ComplexTypeBase
}

func BitListType

func BitListType(limit uint64) *BitListTypeDef

func (*BitListTypeDef) BottomNodeLimit

func (td *BitListTypeDef) BottomNodeLimit() uint64

func (*BitListTypeDef) Default

func (td *BitListTypeDef) Default(hook BackingHook) View

func (*BitListTypeDef) DefaultNode

func (td *BitListTypeDef) DefaultNode() Node

func (*BitListTypeDef) Deserialize

func (td *BitListTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*BitListTypeDef) FromBits

func (td *BitListTypeDef) FromBits(bits []bool) (*BitListView, error)

func (*BitListTypeDef) Limit

func (td *BitListTypeDef) Limit() uint64

func (*BitListTypeDef) New

func (td *BitListTypeDef) New() *BitListView

func (*BitListTypeDef) String

func (td *BitListTypeDef) String() string

func (*BitListTypeDef) ViewFromBacking

func (td *BitListTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type BitListView

type BitListView struct {
	SubtreeView
	*BitListTypeDef
}

func AsBitList

func AsBitList(v View, err error) (*BitListView, error)

func (*BitListView) Append

func (tv *BitListView) Append(view BoolView) error

func (*BitListView) CheckIndex

func (tv *BitListView) CheckIndex(i uint64) error

func (*BitListView) Copy

func (tv *BitListView) Copy() (View, error)

func (*BitListView) Get

func (tv *BitListView) Get(i uint64) (BoolView, error)

func (*BitListView) Iter

func (tv *BitListView) Iter() BitIter

func (*BitListView) Length

func (tv *BitListView) Length() (uint64, error)

func (*BitListView) Pop

func (tv *BitListView) Pop() error

func (*BitListView) ReadonlyIter

func (tv *BitListView) ReadonlyIter() BitIter

func (*BitListView) Serialize

func (tv *BitListView) Serialize(w *codec.EncodingWriter) error

func (*BitListView) Set

func (tv *BitListView) Set(i uint64, v BoolView) error

func (*BitListView) ValueByteLength

func (tv *BitListView) ValueByteLength() (uint64, error)

type BitVectorTypeDef

type BitVectorTypeDef struct {
	BitLength uint64
	ComplexTypeBase
}

func BitVectorType

func BitVectorType(length uint64) *BitVectorTypeDef

func (*BitVectorTypeDef) BottomNodeLength

func (td *BitVectorTypeDef) BottomNodeLength() uint64

func (*BitVectorTypeDef) Default

func (td *BitVectorTypeDef) Default(hook BackingHook) View

func (*BitVectorTypeDef) DefaultNode

func (td *BitVectorTypeDef) DefaultNode() Node

func (*BitVectorTypeDef) Deserialize

func (td *BitVectorTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*BitVectorTypeDef) FromBits

func (td *BitVectorTypeDef) FromBits(bits []bool) (*BitVectorView, error)

func (*BitVectorTypeDef) Length

func (td *BitVectorTypeDef) Length() uint64

func (*BitVectorTypeDef) New

func (td *BitVectorTypeDef) New() *BitVectorView

func (*BitVectorTypeDef) String

func (td *BitVectorTypeDef) String() string

func (*BitVectorTypeDef) ViewFromBacking

func (td *BitVectorTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type BitVectorView

type BitVectorView struct {
	SubtreeView
	*BitVectorTypeDef
}

func AsBitVector

func AsBitVector(v View, err error) (*BitVectorView, error)

func (*BitVectorView) Copy

func (tv *BitVectorView) Copy() (View, error)

func (*BitVectorView) Get

func (tv *BitVectorView) Get(i uint64) (BoolView, error)

func (*BitVectorView) Iter

func (tv *BitVectorView) Iter() BitIter

func (*BitVectorView) ReadonlyIter

func (tv *BitVectorView) ReadonlyIter() BitIter

func (*BitVectorView) Serialize

func (tv *BitVectorView) Serialize(w *codec.EncodingWriter) error

func (*BitVectorView) Set

func (tv *BitVectorView) Set(i uint64, v BoolView) error

func (*BitVectorView) ValueByteLength

func (tv *BitVectorView) ValueByteLength() (uint64, error)

type BoolMeta

type BoolMeta uint8
const BoolType BoolMeta = 0

func (BoolMeta) BoolViewFromBitfieldBacking

func (td BoolMeta) BoolViewFromBitfieldBacking(v *Root, i uint8) (BoolView, error)

func (BoolMeta) Default

func (td BoolMeta) Default(_ BackingHook) View

func (BoolMeta) DefaultNode

func (td BoolMeta) DefaultNode() Node

func (BoolMeta) Deserialize

func (td BoolMeta) Deserialize(dr *codec.DecodingReader) (View, error)

func (BoolMeta) IsFixedByteLength

func (td BoolMeta) IsFixedByteLength() bool

func (BoolMeta) MaxByteLength

func (td BoolMeta) MaxByteLength() uint64

func (BoolMeta) MinByteLength

func (td BoolMeta) MinByteLength() uint64

func (BoolMeta) New

func (td BoolMeta) New() BoolView

func (BoolMeta) String

func (td BoolMeta) String() string

func (BoolMeta) SubViewFromBacking

func (td BoolMeta) SubViewFromBacking(v *Root, i uint8) BasicView

func (BoolMeta) TypeByteLength

func (td BoolMeta) TypeByteLength() uint64

func (BoolMeta) ViewFromBacking

func (td BoolMeta) ViewFromBacking(node Node, _ BackingHook) (View, error)

type BoolView

type BoolView bool

func AsBool

func AsBool(v View, err error) (BoolView, error)

func (BoolView) Backing

func (v BoolView) Backing() Node

func (BoolView) BackingFromBase

func (v BoolView) BackingFromBase(base *Root, i uint8) *Root

func (BoolView) BackingFromBitfieldBase

func (v BoolView) BackingFromBitfieldBase(base *Root, i uint8) *Root

func (BoolView) ByteLength added in v0.1.0

func (v BoolView) ByteLength() uint64

func (BoolView) Copy

func (v BoolView) Copy() (View, error)

func (*BoolView) Decode added in v0.1.0

func (v *BoolView) Decode(x []byte) error

func (*BoolView) Deserialize added in v0.1.0

func (v *BoolView) Deserialize(r *codec.DecodingReader) error

func (BoolView) Encode added in v0.1.0

func (v BoolView) Encode() ([]byte, error)

func (BoolView) FixedLength added in v0.1.0

func (v BoolView) FixedLength() uint64

func (BoolView) HashTreeRoot

func (v BoolView) HashTreeRoot(h HashFn) Root

func (BoolView) Serialize

func (v BoolView) Serialize(w *codec.EncodingWriter) error

func (BoolView) SetBacking

func (v BoolView) SetBacking(b Node) error

func (BoolView) String added in v0.1.2

func (v BoolView) String() string

func (BoolView) Type

func (v BoolView) Type() TypeDef

func (BoolView) ValueByteLength

func (v BoolView) ValueByteLength() (uint64, error)

type ByteView

type ByteView = Uint8View

Alias to Uint8View

func AsByte

func AsByte(v View, err error) (ByteView, error)

type ComplexListTypeDef

type ComplexListTypeDef struct {
	ElemType  TypeDef
	ListLimit uint64
	ComplexTypeBase
}

func ComplexListType

func ComplexListType(elemType TypeDef, limit uint64) *ComplexListTypeDef

func (*ComplexListTypeDef) Default

func (td *ComplexListTypeDef) Default(hook BackingHook) View

func (*ComplexListTypeDef) DefaultNode

func (td *ComplexListTypeDef) DefaultNode() Node

func (*ComplexListTypeDef) Deserialize

func (td *ComplexListTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*ComplexListTypeDef) ElementType

func (td *ComplexListTypeDef) ElementType() TypeDef

func (*ComplexListTypeDef) FromElements

func (td *ComplexListTypeDef) FromElements(v ...View) (*ComplexListView, error)

func (*ComplexListTypeDef) Limit

func (td *ComplexListTypeDef) Limit() uint64

func (*ComplexListTypeDef) New

func (*ComplexListTypeDef) String

func (td *ComplexListTypeDef) String() string

func (*ComplexListTypeDef) ViewFromBacking

func (td *ComplexListTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type ComplexListView

type ComplexListView struct {
	SubtreeView
	*ComplexListTypeDef
}

func AsComplexList

func AsComplexList(v View, err error) (*ComplexListView, error)

func (*ComplexListView) Append

func (tv *ComplexListView) Append(v View) error

func (*ComplexListView) CheckIndex

func (tv *ComplexListView) CheckIndex(i uint64) error

func (*ComplexListView) Copy

func (tv *ComplexListView) Copy() (View, error)

func (*ComplexListView) Get

func (tv *ComplexListView) Get(i uint64) (View, error)

func (*ComplexListView) ItemHook

func (tv *ComplexListView) ItemHook(i uint64) BackingHook

func (*ComplexListView) Iter

func (tv *ComplexListView) Iter() ElemIter

func (*ComplexListView) Length

func (tv *ComplexListView) Length() (uint64, error)

func (*ComplexListView) Pop

func (tv *ComplexListView) Pop() error

func (*ComplexListView) ReadonlyIter

func (tv *ComplexListView) ReadonlyIter() ElemIter

func (*ComplexListView) Serialize

func (tv *ComplexListView) Serialize(w *codec.EncodingWriter) error

func (*ComplexListView) Set

func (tv *ComplexListView) Set(i uint64, v View) error

func (*ComplexListView) ValueByteLength

func (tv *ComplexListView) ValueByteLength() (uint64, error)

type ComplexTypeBase

type ComplexTypeBase struct {
	MinSize     uint64
	MaxSize     uint64
	Size        uint64
	IsFixedSize bool
}

func (*ComplexTypeBase) IsFixedByteLength

func (td *ComplexTypeBase) IsFixedByteLength() bool

func (*ComplexTypeBase) MaxByteLength

func (td *ComplexTypeBase) MaxByteLength() uint64

func (*ComplexTypeBase) MinByteLength

func (td *ComplexTypeBase) MinByteLength() uint64

func (*ComplexTypeBase) TypeByteLength

func (td *ComplexTypeBase) TypeByteLength() uint64

type ComplexVectorTypeDef

type ComplexVectorTypeDef struct {
	ElemType     TypeDef
	VectorLength uint64
	ComplexTypeBase
}

func ComplexVectorType

func ComplexVectorType(elemType TypeDef, length uint64) *ComplexVectorTypeDef

func (*ComplexVectorTypeDef) Default

func (td *ComplexVectorTypeDef) Default(hook BackingHook) View

func (*ComplexVectorTypeDef) DefaultNode

func (td *ComplexVectorTypeDef) DefaultNode() Node

func (*ComplexVectorTypeDef) Deserialize

func (td *ComplexVectorTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*ComplexVectorTypeDef) ElementType

func (td *ComplexVectorTypeDef) ElementType() TypeDef

func (*ComplexVectorTypeDef) FromElements

func (td *ComplexVectorTypeDef) FromElements(v ...View) (*ComplexVectorView, error)

func (*ComplexVectorTypeDef) Length

func (td *ComplexVectorTypeDef) Length() uint64

func (*ComplexVectorTypeDef) New

func (*ComplexVectorTypeDef) String

func (td *ComplexVectorTypeDef) String() string

func (*ComplexVectorTypeDef) ViewFromBacking

func (td *ComplexVectorTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type ComplexVectorView

type ComplexVectorView struct {
	SubtreeView
	*ComplexVectorTypeDef
}

func AsComplexVector

func AsComplexVector(v View, err error) (*ComplexVectorView, error)

func (*ComplexVectorView) Copy

func (tv *ComplexVectorView) Copy() (View, error)

func (*ComplexVectorView) Get

func (tv *ComplexVectorView) Get(i uint64) (View, error)

func (*ComplexVectorView) ItemHook

func (tv *ComplexVectorView) ItemHook(i uint64) BackingHook

func (*ComplexVectorView) Iter

func (tv *ComplexVectorView) Iter() ElemIter

func (*ComplexVectorView) ReadonlyIter

func (tv *ComplexVectorView) ReadonlyIter() ElemIter

func (*ComplexVectorView) Serialize

func (tv *ComplexVectorView) Serialize(w *codec.EncodingWriter) error

func (*ComplexVectorView) Set

func (tv *ComplexVectorView) Set(i uint64, v View) error

func (*ComplexVectorView) ValueByteLength

func (tv *ComplexVectorView) ValueByteLength() (uint64, error)

type ContainerTypeDef

type ContainerTypeDef struct {
	ComplexTypeBase
	ContainerName string
	Fields        []FieldDef
	OffsetsCount  uint64
	FixedPartSize uint64
}

func ContainerType

func ContainerType(name string, fields []FieldDef) *ContainerTypeDef

func (*ContainerTypeDef) Default

func (td *ContainerTypeDef) Default(hook BackingHook) View

func (*ContainerTypeDef) DefaultNode

func (td *ContainerTypeDef) DefaultNode() Node

func (*ContainerTypeDef) Deserialize

func (td *ContainerTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*ContainerTypeDef) FieldCount

func (td *ContainerTypeDef) FieldCount() uint64

func (*ContainerTypeDef) FromFields

func (td *ContainerTypeDef) FromFields(v ...View) (*ContainerView, error)

func (*ContainerTypeDef) New

func (td *ContainerTypeDef) New() *ContainerView

func (*ContainerTypeDef) String

func (td *ContainerTypeDef) String() string

func (*ContainerTypeDef) TypeRepr

func (td *ContainerTypeDef) TypeRepr() string

func (*ContainerTypeDef) ViewFromBacking

func (td *ContainerTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type ContainerView

type ContainerView struct {
	SubtreeView
	*ContainerTypeDef
}

func AsContainer

func AsContainer(v View, err error) (*ContainerView, error)

func (*ContainerView) Copy

func (tv *ContainerView) Copy() (View, error)

func (*ContainerView) FieldValues

func (tv *ContainerView) FieldValues() ([]View, error)

func (*ContainerView) Get

func (tv *ContainerView) Get(i uint64) (View, error)

func (*ContainerView) ItemHook

func (tv *ContainerView) ItemHook(i uint64) BackingHook

func (*ContainerView) Iter

func (tv *ContainerView) Iter() ElemIter

func (*ContainerView) ReadonlyIter

func (tv *ContainerView) ReadonlyIter() ElemIter

func (*ContainerView) Serialize

func (tv *ContainerView) Serialize(w *codec.EncodingWriter) error

func (*ContainerView) Set

func (tv *ContainerView) Set(i uint64, v View) error

func (*ContainerView) ValueByteLength

func (tv *ContainerView) ValueByteLength() (uint64, error)

type ElemIter

type ElemIter interface {
	// Next gets the next element, ok is true if it actually exists.
	// An error may occur if data is missing or corrupt.
	Next() (elem View, ok bool, err error)
}

type ElemIterFn

type ElemIterFn func() (elem View, ok bool, err error)

func (ElemIterFn) Next

func (f ElemIterFn) Next() (elem View, ok bool, err error)

type ErrBitIter

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

func (ErrBitIter) Next

func (e ErrBitIter) Next() (elem bool, ok bool, err error)

type ErrElemIter

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

func (ErrElemIter) Next

func (e ErrElemIter) Next() (elem View, ok bool, err error)

type ErrNodeIter

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

func (ErrNodeIter) Next

func (e ErrNodeIter) Next() (chunk Node, ok bool, err error)

type FieldDef

type FieldDef struct {
	Name string
	Type TypeDef
}

type ListTypeDef

type ListTypeDef interface {
	TypeDef
	ElementType() TypeDef
	Limit() uint64
}

func ListType

func ListType(elemType TypeDef, limit uint64) ListTypeDef

type NodeIter

type NodeIter interface {
	// Next gets the next node, ok is true if it actually exists.
	// An error may occur if data is missing or corrupt.
	Next() (chunk Node, ok bool, err error)
}

type NodeIterFn

type NodeIterFn func() (chunk Node, ok bool, err error)

func (NodeIterFn) Next

func (f NodeIterFn) Next() (chunk Node, ok bool, err error)

type RootMeta

type RootMeta uint8
const RootType RootMeta = 0

func (RootMeta) Default

func (m RootMeta) Default(hook BackingHook) View

func (RootMeta) DefaultNode

func (RootMeta) DefaultNode() Node

func (RootMeta) Deserialize

func (m RootMeta) Deserialize(dr *codec.DecodingReader) (View, error)

func (RootMeta) IsFixedByteLength

func (m RootMeta) IsFixedByteLength() bool

func (RootMeta) MaxByteLength

func (m RootMeta) MaxByteLength() uint64

func (RootMeta) MinByteLength

func (m RootMeta) MinByteLength() uint64

func (RootMeta) Name

func (m RootMeta) Name() string

func (RootMeta) String

func (m RootMeta) String() string

func (RootMeta) TypeByteLength

func (m RootMeta) TypeByteLength() uint64

func (RootMeta) ViewFromBacking

func (RootMeta) ViewFromBacking(node Node, _ BackingHook) (View, error)

type RootView

type RootView Root

func (*RootView) Backing

func (r *RootView) Backing() Node

Backing, a root can be used as a view representing itself.

func (*RootView) Copy

func (r *RootView) Copy() (View, error)

func (*RootView) HashTreeRoot

func (r *RootView) HashTreeRoot(h HashFn) Root

func (*RootView) MarshalText added in v0.1.1

func (r *RootView) MarshalText() ([]byte, error)

func (*RootView) Serialize

func (r *RootView) Serialize(w *codec.EncodingWriter) error

func (*RootView) SetBacking

func (r *RootView) SetBacking(b Node) error

func (*RootView) String added in v0.1.2

func (r *RootView) String() string

func (*RootView) Type

func (r *RootView) Type() TypeDef

func (*RootView) UnmarshalText added in v0.1.1

func (r *RootView) UnmarshalText(text []byte) error

func (*RootView) ValueByteLength

func (r *RootView) ValueByteLength() (uint64, error)

type SmallByteVecMeta

type SmallByteVecMeta uint8

To represent views of < 32 bytes efficiently as just a slice of those bytes. Values above 32 are invalid. For 32, using Root ([32]byte as underlying type) is better.

const Bytes16Type SmallByteVecMeta = 16
const Bytes4Type SmallByteVecMeta = 4
const Bytes8Type SmallByteVecMeta = 8

func (SmallByteVecMeta) Default

func (td SmallByteVecMeta) Default(_ BackingHook) View

func (SmallByteVecMeta) DefaultNode

func (td SmallByteVecMeta) DefaultNode() Node

func (SmallByteVecMeta) Deserialize

func (td SmallByteVecMeta) Deserialize(dr *codec.DecodingReader) (View, error)

func (SmallByteVecMeta) IsFixedByteLength

func (td SmallByteVecMeta) IsFixedByteLength() bool

func (SmallByteVecMeta) MaxByteLength

func (td SmallByteVecMeta) MaxByteLength() uint64

func (SmallByteVecMeta) MinByteLength

func (td SmallByteVecMeta) MinByteLength() uint64

func (SmallByteVecMeta) New

func (SmallByteVecMeta) String

func (td SmallByteVecMeta) String() string

func (SmallByteVecMeta) TypeByteLength

func (td SmallByteVecMeta) TypeByteLength() uint64

func (SmallByteVecMeta) ViewFromBacking

func (td SmallByteVecMeta) ViewFromBacking(node Node, _ BackingHook) (View, error)

type SmallByteVecView

type SmallByteVecView []byte

func AsSmallByteVec

func AsSmallByteVec(v View, err error) (SmallByteVecView, error)

func (SmallByteVecView) Backing

func (v SmallByteVecView) Backing() Node

func (SmallByteVecView) Copy

func (v SmallByteVecView) Copy() (View, error)

func (SmallByteVecView) HashTreeRoot

func (v SmallByteVecView) HashTreeRoot(h HashFn) Root

func (SmallByteVecView) MarshalText added in v0.1.1

func (v SmallByteVecView) MarshalText() ([]byte, error)

func (SmallByteVecView) Serialize

func (v SmallByteVecView) Serialize(w *codec.EncodingWriter) error

func (SmallByteVecView) SetBacking

func (v SmallByteVecView) SetBacking(b Node) error

func (SmallByteVecView) String added in v0.1.2

func (v SmallByteVecView) String() string

func (SmallByteVecView) Type

func (v SmallByteVecView) Type() TypeDef

func (SmallByteVecView) UnmarshalText added in v0.1.1

func (v SmallByteVecView) UnmarshalText(text []byte) error

func (SmallByteVecView) ValueByteLength

func (v SmallByteVecView) ValueByteLength() (uint64, error)

type SubtreeView

type SubtreeView struct {
	BackedView
	// contains filtered or unexported fields
}

func (*SubtreeView) GetNode

func (stv *SubtreeView) GetNode(i uint64) (Node, error)

func (*SubtreeView) SetNode

func (stv *SubtreeView) SetNode(i uint64, node Node) error

type TypeDef

type TypeDef interface {
	Default(hook BackingHook) View
	DefaultNode() Node
	ViewFromBacking(node Node, hook BackingHook) (View, error)
	IsFixedByteLength() bool
	// 0 if there type has no single fixed byte length
	TypeByteLength() uint64
	MinByteLength() uint64
	MaxByteLength() uint64
	Deserialize(dr *codec.DecodingReader) (View, error)
	String() string
}

type Uint16View

type Uint16View uint16

func AsUint16

func AsUint16(v View, err error) (Uint16View, error)

func (Uint16View) Backing

func (v Uint16View) Backing() Node

func (Uint16View) BackingFromBase

func (v Uint16View) BackingFromBase(base *Root, i uint8) *Root

func (Uint16View) ByteLength added in v0.1.0

func (v Uint16View) ByteLength() uint64

func (Uint16View) Copy

func (v Uint16View) Copy() (View, error)

func (*Uint16View) Decode added in v0.1.0

func (v *Uint16View) Decode(x []byte) error

func (*Uint16View) Deserialize added in v0.1.0

func (v *Uint16View) Deserialize(r *codec.DecodingReader) error

func (Uint16View) Encode added in v0.1.0

func (v Uint16View) Encode() ([]byte, error)

func (Uint16View) FixedLength added in v0.1.0

func (v Uint16View) FixedLength() uint64

func (Uint16View) HashTreeRoot

func (v Uint16View) HashTreeRoot(h HashFn) Root

func (Uint16View) MarshalJSON added in v0.2.0

func (v Uint16View) MarshalJSON() ([]byte, error)

func (Uint16View) MarshalText added in v0.2.0

func (v Uint16View) MarshalText() (out []byte, err error)

func (Uint16View) Serialize

func (v Uint16View) Serialize(w *codec.EncodingWriter) error

func (Uint16View) SetBacking

func (v Uint16View) SetBacking(b Node) error

func (Uint16View) String added in v0.1.2

func (v Uint16View) String() string

func (Uint16View) Type

func (v Uint16View) Type() TypeDef

func (*Uint16View) UnmarshalJSON added in v0.2.0

func (v *Uint16View) UnmarshalJSON(b []byte) error

func (*Uint16View) UnmarshalText added in v0.2.0

func (v *Uint16View) UnmarshalText(b []byte) error

func (Uint16View) ValueByteLength

func (v Uint16View) ValueByteLength() (uint64, error)

type Uint256View added in v0.2.0

type Uint256View uint256.Int

func AsUint256 added in v0.2.0

func AsUint256(v View, err error) (Uint256View, error)

func MustUint256 added in v0.2.0

func MustUint256(v string) Uint256View

func (Uint256View) Backing added in v0.2.0

func (v Uint256View) Backing() Node

func (Uint256View) BackingFromBase added in v0.2.0

func (v Uint256View) BackingFromBase(base *Root, i uint8) *Root

func (Uint256View) ByteLength added in v0.2.0

func (v Uint256View) ByteLength() uint64

func (Uint256View) Bytes added in v0.2.0

func (v Uint256View) Bytes() []byte

Bytes returns little endian encoding (always 32 bytes)

func (Uint256View) Bytes32 added in v0.2.0

func (v Uint256View) Bytes32() (out [32]byte)

Bytes32 returns little endian encoding

func (Uint256View) Copy added in v0.2.0

func (v Uint256View) Copy() (View, error)

func (*Uint256View) Decode added in v0.2.0

func (v *Uint256View) Decode(x []byte) error

func (*Uint256View) Deserialize added in v0.2.0

func (v *Uint256View) Deserialize(r *codec.DecodingReader) error

func (Uint256View) Encode added in v0.2.0

func (v Uint256View) Encode() ([]byte, error)

func (Uint256View) FixedLength added in v0.2.0

func (v Uint256View) FixedLength() uint64

func (Uint256View) HashTreeRoot added in v0.2.0

func (v Uint256View) HashTreeRoot(h HashFn) Root

func (Uint256View) MarshalJSON added in v0.2.0

func (v Uint256View) MarshalJSON() ([]byte, error)

func (Uint256View) MarshalText added in v0.2.0

func (v Uint256View) MarshalText() (out []byte, err error)

func (Uint256View) Serialize added in v0.2.0

func (v Uint256View) Serialize(w *codec.EncodingWriter) error

func (Uint256View) SetBacking added in v0.2.0

func (v Uint256View) SetBacking(b Node) error

func (*Uint256View) SetBytes32 added in v0.2.0

func (v *Uint256View) SetBytes32(data [32]byte)

SetBytes32 sets view from little endian encoding

func (*Uint256View) SetFromBig added in v0.2.0

func (v *Uint256View) SetFromBig(x *big.Int) (overflow bool)

func (Uint256View) String added in v0.2.0

func (v Uint256View) String() string

func (Uint256View) Type added in v0.2.0

func (v Uint256View) Type() TypeDef

func (*Uint256View) UnmarshalJSON added in v0.2.0

func (v *Uint256View) UnmarshalJSON(b []byte) error

func (*Uint256View) UnmarshalText added in v0.2.0

func (v *Uint256View) UnmarshalText(b []byte) error

func (Uint256View) ValueByteLength added in v0.2.0

func (v Uint256View) ValueByteLength() (uint64, error)

type Uint32View

type Uint32View uint32

func AsUint32

func AsUint32(v View, err error) (Uint32View, error)

func (Uint32View) Backing

func (v Uint32View) Backing() Node

func (Uint32View) BackingFromBase

func (v Uint32View) BackingFromBase(base *Root, i uint8) *Root

func (Uint32View) ByteLength added in v0.1.0

func (v Uint32View) ByteLength() uint64

func (Uint32View) Copy

func (v Uint32View) Copy() (View, error)

func (*Uint32View) Decode added in v0.1.0

func (v *Uint32View) Decode(x []byte) error

func (*Uint32View) Deserialize added in v0.1.0

func (v *Uint32View) Deserialize(r *codec.DecodingReader) error

func (Uint32View) Encode added in v0.1.0

func (v Uint32View) Encode() ([]byte, error)

func (Uint32View) FixedLength added in v0.1.0

func (v Uint32View) FixedLength() uint64

func (Uint32View) HashTreeRoot

func (v Uint32View) HashTreeRoot(h HashFn) Root

func (Uint32View) MarshalJSON added in v0.2.0

func (v Uint32View) MarshalJSON() ([]byte, error)

func (Uint32View) MarshalText added in v0.2.0

func (v Uint32View) MarshalText() (out []byte, err error)

func (Uint32View) Serialize

func (v Uint32View) Serialize(w *codec.EncodingWriter) error

func (Uint32View) SetBacking

func (v Uint32View) SetBacking(b Node) error

func (Uint32View) String added in v0.1.2

func (v Uint32View) String() string

func (Uint32View) Type

func (v Uint32View) Type() TypeDef

func (*Uint32View) UnmarshalJSON added in v0.2.0

func (v *Uint32View) UnmarshalJSON(b []byte) error

func (*Uint32View) UnmarshalText added in v0.2.0

func (v *Uint32View) UnmarshalText(b []byte) error

func (Uint32View) ValueByteLength

func (v Uint32View) ValueByteLength() (uint64, error)

type Uint64View

type Uint64View uint64

func AsUint64

func AsUint64(v View, err error) (Uint64View, error)

func (Uint64View) Backing

func (v Uint64View) Backing() Node

func (Uint64View) BackingFromBase

func (v Uint64View) BackingFromBase(base *Root, i uint8) *Root

func (Uint64View) ByteLength added in v0.1.0

func (v Uint64View) ByteLength() uint64

func (Uint64View) Copy

func (v Uint64View) Copy() (View, error)

func (*Uint64View) Decode added in v0.1.0

func (v *Uint64View) Decode(x []byte) error

func (*Uint64View) Deserialize added in v0.1.0

func (v *Uint64View) Deserialize(r *codec.DecodingReader) error

func (Uint64View) Encode added in v0.1.0

func (v Uint64View) Encode() ([]byte, error)

func (Uint64View) FixedLength added in v0.1.0

func (v Uint64View) FixedLength() uint64

func (Uint64View) HashTreeRoot

func (v Uint64View) HashTreeRoot(h HashFn) Root

func (Uint64View) MarshalJSON added in v0.1.1

func (v Uint64View) MarshalJSON() ([]byte, error)

func (Uint64View) MarshalText added in v0.2.0

func (v Uint64View) MarshalText() (out []byte, err error)

func (Uint64View) Serialize

func (v Uint64View) Serialize(w *codec.EncodingWriter) error

func (Uint64View) SetBacking

func (v Uint64View) SetBacking(b Node) error

func (Uint64View) String added in v0.1.2

func (v Uint64View) String() string

func (Uint64View) Type

func (v Uint64View) Type() TypeDef

func (*Uint64View) UnmarshalJSON added in v0.1.1

func (v *Uint64View) UnmarshalJSON(b []byte) error

func (*Uint64View) UnmarshalText added in v0.2.0

func (v *Uint64View) UnmarshalText(b []byte) error

func (Uint64View) ValueByteLength

func (v Uint64View) ValueByteLength() (uint64, error)

type Uint8View

type Uint8View uint8

func AsUint8

func AsUint8(v View, err error) (Uint8View, error)

func (Uint8View) Backing

func (v Uint8View) Backing() Node

func (Uint8View) BackingFromBase

func (v Uint8View) BackingFromBase(base *Root, i uint8) *Root

func (Uint8View) ByteLength added in v0.1.0

func (v Uint8View) ByteLength() uint64

func (Uint8View) Copy

func (v Uint8View) Copy() (View, error)

func (*Uint8View) Decode added in v0.1.0

func (v *Uint8View) Decode(x []byte) error

func (*Uint8View) Deserialize added in v0.1.0

func (v *Uint8View) Deserialize(r *codec.DecodingReader) error

func (Uint8View) Encode added in v0.1.0

func (v Uint8View) Encode() ([]byte, error)

func (Uint8View) FixedLength added in v0.1.0

func (v Uint8View) FixedLength() uint64

func (Uint8View) HashTreeRoot

func (v Uint8View) HashTreeRoot(h HashFn) Root

func (Uint8View) MarshalJSON added in v0.2.0

func (v Uint8View) MarshalJSON() ([]byte, error)

func (Uint8View) MarshalText added in v0.2.0

func (v Uint8View) MarshalText() (out []byte, err error)

func (Uint8View) Serialize

func (v Uint8View) Serialize(w *codec.EncodingWriter) error

func (Uint8View) SetBacking

func (v Uint8View) SetBacking(b Node) error

func (Uint8View) String added in v0.1.2

func (v Uint8View) String() string

func (Uint8View) Type

func (v Uint8View) Type() TypeDef

func (*Uint8View) UnmarshalJSON added in v0.2.0

func (v *Uint8View) UnmarshalJSON(b []byte) error

func (*Uint8View) UnmarshalText added in v0.2.0

func (v *Uint8View) UnmarshalText(b []byte) error

func (Uint8View) ValueByteLength

func (v Uint8View) ValueByteLength() (uint64, error)

type UintMeta

type UintMeta uint64

A uint type, identified by its size in bytes.

const (
	Uint8Type   UintMeta = 1
	Uint16Type  UintMeta = 2
	Uint32Type  UintMeta = 4
	Uint64Type  UintMeta = 8
	Uint128Type UintMeta = 16
	Uint256Type UintMeta = 32
)

func (UintMeta) BasicViewFromBacking

func (td UintMeta) BasicViewFromBacking(v *Root, i uint8) (BasicView, error)

func (UintMeta) Default

func (td UintMeta) Default(_ BackingHook) View

func (UintMeta) DefaultNode

func (td UintMeta) DefaultNode() Node

func (UintMeta) Deserialize

func (td UintMeta) Deserialize(dr *codec.DecodingReader) (View, error)

func (UintMeta) IsFixedByteLength

func (td UintMeta) IsFixedByteLength() bool

func (UintMeta) MaxByteLength

func (td UintMeta) MaxByteLength() uint64

func (UintMeta) MinByteLength

func (td UintMeta) MinByteLength() uint64

func (UintMeta) New

func (td UintMeta) New() BasicView

func (UintMeta) PackViews

func (td UintMeta) PackViews(views []BasicView) ([]Node, error)

func (UintMeta) String

func (td UintMeta) String() string

func (UintMeta) TypeByteLength

func (td UintMeta) TypeByteLength() uint64

func (UintMeta) ViewFromBacking

func (td UintMeta) ViewFromBacking(node Node, _ BackingHook) (View, error)

type UnionTypeDef added in v0.1.7

type UnionTypeDef struct {
	ComplexTypeBase
	// a "None" option is just a nil.
	Options []TypeDef
}

func UnionType added in v0.1.7

func UnionType(options []TypeDef) *UnionTypeDef

func (*UnionTypeDef) Default added in v0.1.7

func (td *UnionTypeDef) Default(hook BackingHook) View

func (*UnionTypeDef) DefaultNode added in v0.1.7

func (td *UnionTypeDef) DefaultNode() Node

func (*UnionTypeDef) Deserialize added in v0.1.7

func (td *UnionTypeDef) Deserialize(dr *codec.DecodingReader) (View, error)

func (*UnionTypeDef) FromView added in v0.1.7

func (td *UnionTypeDef) FromView(selector uint8, v View) (*UnionView, error)

func (*UnionTypeDef) New added in v0.1.7

func (td *UnionTypeDef) New() *UnionView

func (*UnionTypeDef) String added in v0.1.7

func (td *UnionTypeDef) String() string

func (*UnionTypeDef) TypeRepr added in v0.1.7

func (td *UnionTypeDef) TypeRepr() string

func (*UnionTypeDef) ViewFromBacking added in v0.1.7

func (td *UnionTypeDef) ViewFromBacking(node Node, hook BackingHook) (View, error)

type UnionView added in v0.1.7

type UnionView struct {
	BackedView
	*UnionTypeDef
}

func AsUnion added in v0.1.7

func AsUnion(v View, err error) (*UnionView, error)

func (*UnionView) Change added in v0.1.7

func (tv *UnionView) Change(selector uint8, value View) error

Changes the union selector and value. Does not check the view type. The value may be nil in the Union[None, T...] case.

func (*UnionView) Copy added in v0.1.7

func (tv *UnionView) Copy() (View, error)

func (*UnionView) Selector added in v0.1.7

func (tv *UnionView) Selector() (uint8, error)

func (*UnionView) Serialize added in v0.1.7

func (tv *UnionView) Serialize(w *codec.EncodingWriter) error

func (*UnionView) Value added in v0.1.7

func (tv *UnionView) Value() (View, error)

Return the value. May be nil if it's a Union[None, T...]

func (*UnionView) ValueByteLength added in v0.1.7

func (tv *UnionView) ValueByteLength() (uint64, error)

type VectorTypeDef

type VectorTypeDef interface {
	TypeDef
	ElementType() TypeDef
	Length() uint64
}

func VectorType

func VectorType(elemType TypeDef, length uint64) VectorTypeDef

type View

type View interface {
	Backing() Node
	SetBacking(b Node) error
	Copy() (View, error)
	ValueByteLength() (uint64, error)
	Serialize(w *codec.EncodingWriter) error
	HashTreeRoot(h HashFn) Root
	Type() TypeDef
}

type ViewBase

type ViewBase struct {
	TypeDef TypeDef
}

func (*ViewBase) Type

func (v *ViewBase) Type() TypeDef

Jump to

Keyboard shortcuts

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