Documentation ¶
Index ¶
- type AttrEncID
- type TVEnc
- func (enc *TVEnc) Bytes() ([]byte, error)
- func (enc *TVEnc) Encode(item any)
- func (enc *TVEnc) EncodeTagged(tag Tag, item any)
- func (enc *TVEnc) WriteBytes(value []byte)
- func (enc *TVEnc) WriteString(value string)
- func (enc *TVEnc) WriteUInt16(value uint16)
- func (enc *TVEnc) WriteUInt32(value uint32)
- func (enc *TVEnc) WriteUInt64(value uint64)
- type TXSystemEncoder
- func (enc TXSystemEncoder) Encode(obj any, ver uint32, getHandle func(obj any) uint64) ([]byte, error)
- func (enc *TXSystemEncoder) RegisterAttrEncoder(id AttrEncID, encoder TxAttributesEncoder) error
- func (enc *TXSystemEncoder) RegisterTxAttributeEncoders(reg func(func(id AttrEncID, enc TxAttributesEncoder) error) error, ...) error
- func (enc *TXSystemEncoder) RegisterUnitDataEncoder(ud any, encoder UnitDataEncoder) error
- func (enc TXSystemEncoder) TxAttributes(txo *types.TransactionOrder, ver uint32) ([]byte, error)
- func (enc TXSystemEncoder) UnitData(unit *state.Unit, ver uint32) ([]byte, error)
- type Tag
- type TxAttributesEncoder
- type UnitDataEncoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttrEncID ¶
type AttrEncID struct { TxSys types.PartitionID Attr uint16 // tx type id }
tx attribute encoder ID
type TVEnc ¶
type TVEnc struct {
// contains filtered or unexported fields
}
TVEnc is an encoder for serializing data info format which can be parsed by Alphabill Rust predicate SDK.
Encodes simple data as {type id; data} pairs, to encode more complex data structures additional "tag" can be assigned to each "data record" (see EncodeTagged method).
func (*TVEnc) Bytes ¶
Bytes returns the serialized representation of the data so far and error if any happened during encoding. Buffer is not reset!
func (*TVEnc) EncodeTagged ¶
func (*TVEnc) WriteBytes ¶
func (*TVEnc) WriteString ¶
func (*TVEnc) WriteUInt16 ¶
func (*TVEnc) WriteUInt32 ¶
func (*TVEnc) WriteUInt64 ¶
type TXSystemEncoder ¶
type TXSystemEncoder struct {
// contains filtered or unexported fields
}
TXSystemEncoder is "generic" tx system encoder, parts specific to given tx system (which wants to use it with Wazero WASM predicates) must be added using Register*Encoder methods.
func New ¶
func New(f ...any) (TXSystemEncoder, error)
func (TXSystemEncoder) Encode ¶
func (enc TXSystemEncoder) Encode(obj any, ver uint32, getHandle func(obj any) uint64) ([]byte, error)
Encode serializes well known types (not tx system specific) to representation WASM predicate SDK can load.
- obj: data to serialize, must be of "well known type";
- ver: version of the encoding/object the predicate expects;
- getHandle: callback to register variable in the execution context, returns handle of the new variable. Ie instead of "flattening" sub-object it can be registered and it's handle returned as part of response allowing predicate to load the sub-object with next call.
func (*TXSystemEncoder) RegisterAttrEncoder ¶
func (enc *TXSystemEncoder) RegisterAttrEncoder(id AttrEncID, encoder TxAttributesEncoder) error
RegisterAttrEncoder registers tx attribute encoder.
func (*TXSystemEncoder) RegisterTxAttributeEncoders ¶
func (enc *TXSystemEncoder) RegisterTxAttributeEncoders(reg func(func(id AttrEncID, enc TxAttributesEncoder) error) error, filter func(AttrEncID) bool) error
RegisterTxAttributeEncoders is like RegisterAttrEncoder but allows to filter out undesired encoders.
- reg: func which attempts to register "all" encoders but for each "filter" is executed and only these for which filter returned true actual registration is attempted.
func (*TXSystemEncoder) RegisterUnitDataEncoder ¶
func (enc *TXSystemEncoder) RegisterUnitDataEncoder(ud any, encoder UnitDataEncoder) error
func (TXSystemEncoder) TxAttributes ¶
func (enc TXSystemEncoder) TxAttributes(txo *types.TransactionOrder, ver uint32) ([]byte, error)
type TxAttributesEncoder ¶
type TxAttributesEncoder func(txo *types.TransactionOrder, ver uint32) ([]byte, error)
returns tx order attributes encoded to WASM representation