Documentation ¶
Index ¶
- Variables
- func BE() binary.ByteOrder
- func ByteCount(v interface{}) (uint64, error)
- func LE() binary.ByteOrder
- func MarshalBinary(v interface{}) ([]byte, error)
- func MustByteCount(v interface{}) uint64
- type BaseVariant
- func (a *BaseVariant) Assign(typeID uint32, impl interface{})
- func (a *BaseVariant) MarshalJSON(def *VariantDefinition) ([]byte, error)
- func (a *BaseVariant) Obtain(def *VariantDefinition) (typeID uint32, typeName string, impl interface{})
- func (a *BaseVariant) UnmarshalBinaryVariant(decoder *Decoder, def *VariantDefinition) (err error)
- func (a *BaseVariant) UnmarshalJSON(data []byte, def *VariantDefinition) error
- type Bool
- type Decoder
- func (d *Decoder) Decode(v interface{}) (err error)
- func (d *Decoder) HasRemaining() bool
- func (d *Decoder) Position() uint
- func (d *Decoder) ReadBool() (out bool, err error)
- func (d *Decoder) ReadByte() (out byte, err error)
- func (d *Decoder) ReadByteArray() (out []byte, err error)
- func (d *Decoder) ReadFloat128(order binary.ByteOrder) (out Float128, err error)
- func (d *Decoder) ReadFloat32(order binary.ByteOrder) (out float32, err error)
- func (d *Decoder) ReadFloat64(order binary.ByteOrder) (out float64, err error)
- func (d *Decoder) ReadInt128(order binary.ByteOrder) (out Int128, err error)
- func (d *Decoder) ReadInt16(order binary.ByteOrder) (out int16, err error)
- func (d *Decoder) ReadInt32(order binary.ByteOrder) (out int32, err error)
- func (d *Decoder) ReadInt64(order binary.ByteOrder) (out int64, err error)
- func (d *Decoder) ReadInt8() (out int8, err error)
- func (d *Decoder) ReadString() (out string, err error)
- func (d *Decoder) ReadUint128(order binary.ByteOrder) (out Uint128, err error)
- func (d *Decoder) ReadUint16(order binary.ByteOrder) (out uint16, err error)
- func (d *Decoder) ReadUint32(order binary.ByteOrder) (out uint32, err error)
- func (d *Decoder) ReadUint64(order binary.ByteOrder) (out uint64, err error)
- func (d *Decoder) ReadUint8() (out uint8, err error)
- func (d *Decoder) ReadUvarint16() (out uint16, err error)
- func (d *Decoder) ReadUvarint32() (out uint32, err error)
- func (d *Decoder) ReadUvarint64() (uint64, error)
- func (d *Decoder) ReadVarint16() (out int16, err error)
- func (d *Decoder) ReadVarint32() (out int32, err error)
- func (d *Decoder) ReadVarint64() (out int64, err error)
- func (d *Decoder) Remaining() int
- func (d *Decoder) SafeReadUTF8String() (out string, err error)
- func (d *Decoder) SetPosition(idx uint) error
- func (d *Decoder) SkipBytes(count uint) error
- type Encoder
- func (e *Encoder) Encode(v interface{}) (err error)
- func (e *Encoder) WriteBool(b bool) (err error)
- func (e *Encoder) WriteByte(b byte) (err error)
- func (e *Encoder) WriteByteArray(b []byte, writeLength bool) error
- func (e *Encoder) WriteFloat32(f float32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteFloat64(f float64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt128(i Int128, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt16(i int16, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt32(i int32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt64(i int64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteRaw(b []byte) error
- func (e *Encoder) WriteString(s string) (err error)
- func (e *Encoder) WriteUVarInt(v int) (err error)
- func (e *Encoder) WriteUint128(i Uint128, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint16(i uint16, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint32(i uint32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint64(i uint64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint8(i uint8) (err error)
- func (e *Encoder) WriteVarInt(v int) (err error)
- type Float128
- type HexBytes
- type Int128
- func (i Int128) BigInt() *big.Int
- func (i Int128) DecimalString() string
- func (i Int128) MarshalBinary(enc *Encoder) error
- func (i Int128) MarshalJSON() (data []byte, err error)
- func (i Int128) String() string
- func (i *Int128) UnmarshalBinary(dec *Decoder) error
- func (i *Int128) UnmarshalJSON(data []byte) error
- type Int64
- type InvalidDecoderError
- type JSONFloat64
- type MarshalerBinary
- type OnVariant
- type SafeString
- type TypeIDEncoding
- type Uint128
- func (i Uint128) BigInt() *big.Int
- func (i Uint128) DecimalString() string
- func (i Uint128) MarshalBinary(enc *Encoder) error
- func (i Uint128) MarshalJSON() (data []byte, err error)
- func (i Uint128) String() string
- func (i *Uint128) UnmarshalBinary(dec *Decoder) error
- func (i *Uint128) UnmarshalJSON(data []byte) error
- type Uint64
- type UnmarshalerBinary
- type Variant
- type VariantDefinition
- type VariantImplFactory
- type VariantType
- type Varint16
- type Varint32
- type Varuint16
- type Varuint32
Constants ¶
This section is empty.
Variables ¶
var ErrVarIntBufferSize = errors.New("varint: invalid buffer size")
var TypeSize = struct { Bool int Byte int Int8 int Int16 int Uint8 int Uint16 int Uint32 int Uint64 int Uint128 int Float32 int Float64 int PublicKey int Signature int Tstamp int BlockTimestamp int CurrencyName int }{ Byte: 1, Bool: 1, Int8: 1, Int16: 2, Uint8: 1, Uint16: 2, Uint32: 4, Uint64: 8, Uint128: 16, Float32: 4, Float64: 8, }
Functions ¶
func ByteCount ¶
ByteCount computes the byte count size for the received populated structure. The reported size is the one for the populated structure received in arguments. Depending on how serialization of your fields is performed, size could vary for different structure.
func MarshalBinary ¶
func MustByteCount ¶
func MustByteCount(v interface{}) uint64
MustByteCount acts just like ByteCount but panics if it encounters any encoding errors.
Types ¶
type BaseVariant ¶
type BaseVariant struct { TypeID uint32 Impl interface{} }
func (*BaseVariant) Assign ¶
func (a *BaseVariant) Assign(typeID uint32, impl interface{})
func (*BaseVariant) MarshalJSON ¶
func (a *BaseVariant) MarshalJSON(def *VariantDefinition) ([]byte, error)
func (*BaseVariant) Obtain ¶
func (a *BaseVariant) Obtain(def *VariantDefinition) (typeID uint32, typeName string, impl interface{})
func (*BaseVariant) UnmarshalBinaryVariant ¶
func (a *BaseVariant) UnmarshalBinaryVariant(decoder *Decoder, def *VariantDefinition) (err error)
func (*BaseVariant) UnmarshalJSON ¶
func (a *BaseVariant) UnmarshalJSON(data []byte, def *VariantDefinition) error
type Bool ¶
type Bool bool
func (Bool) MarshalBinary ¶
func (*Bool) UnmarshalBinary ¶
func (*Bool) UnmarshalJSON ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements the EOS unpacking, similar to FC_BUFFER
func NewDecoder ¶
func (*Decoder) HasRemaining ¶
func (*Decoder) ReadByteArray ¶
func (*Decoder) ReadFloat128 ¶
func (*Decoder) ReadFloat32 ¶
func (*Decoder) ReadFloat64 ¶
func (*Decoder) ReadInt128 ¶
func (*Decoder) ReadString ¶
func (*Decoder) ReadUint128 ¶
func (*Decoder) ReadUint16 ¶
func (*Decoder) ReadUint32 ¶
func (*Decoder) ReadUint64 ¶
func (*Decoder) ReadUvarint16 ¶
func (*Decoder) ReadUvarint32 ¶
func (*Decoder) ReadUvarint64 ¶
func (*Decoder) ReadVarint16 ¶
func (*Decoder) ReadVarint32 ¶
func (*Decoder) ReadVarint64 ¶
func (*Decoder) SafeReadUTF8String ¶
func (*Decoder) SetPosition ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func (*Encoder) WriteFloat32 ¶
func (*Encoder) WriteFloat64 ¶
func (*Encoder) WriteInt128 ¶
func (*Encoder) WriteInt16 ¶
func (*Encoder) WriteInt32 ¶
func (*Encoder) WriteInt64 ¶
func (*Encoder) WriteString ¶
func (*Encoder) WriteUVarInt ¶
func (*Encoder) WriteUint128 ¶
func (*Encoder) WriteUint16 ¶
func (*Encoder) WriteUint32 ¶
func (*Encoder) WriteUint64 ¶
func (*Encoder) WriteUint8 ¶
func (*Encoder) WriteVarInt ¶
type Float128 ¶
type Float128 Uint128
func (Float128) MarshalBinary ¶
func (Float128) MarshalJSON ¶
func (*Float128) UnmarshalBinary ¶
func (*Float128) UnmarshalJSON ¶
type HexBytes ¶
type HexBytes []byte
func (HexBytes) MarshalBinary ¶
func (HexBytes) MarshalJSON ¶
func (*HexBytes) UnmarshalBinary ¶
func (*HexBytes) UnmarshalJSON ¶
type Int128 ¶
type Int128 Uint128
Int128
func (Int128) DecimalString ¶
func (Int128) MarshalBinary ¶
func (Int128) MarshalJSON ¶
func (*Int128) UnmarshalBinary ¶
func (*Int128) UnmarshalJSON ¶
type Int64 ¶
type Int64 int64
func (Int64) MarshalBinary ¶
func (Int64) MarshalJSON ¶
func (*Int64) UnmarshalBinary ¶
func (*Int64) UnmarshalJSON ¶
type InvalidDecoderError ¶
An InvalidDecoderError describes an invalid argument passed to Decoder. (The argument to Decoder must be a non-nil pointer.)
func (*InvalidDecoderError) Error ¶
func (e *InvalidDecoderError) Error() string
type JSONFloat64 ¶
type JSONFloat64 float64
func (JSONFloat64) MarshalBinary ¶
func (f JSONFloat64) MarshalBinary(enc *Encoder) error
func (*JSONFloat64) UnmarshalBinary ¶
func (f *JSONFloat64) UnmarshalBinary(dec *Decoder) error
func (*JSONFloat64) UnmarshalJSON ¶
func (f *JSONFloat64) UnmarshalJSON(data []byte) error
type MarshalerBinary ¶
type SafeString ¶
type SafeString string
func (SafeString) MarshalBinary ¶
func (ss SafeString) MarshalBinary(encoder *Encoder) error
func (*SafeString) UnmarshalBinary ¶
func (ss *SafeString) UnmarshalBinary(d *Decoder) error
type TypeIDEncoding ¶
type TypeIDEncoding uint32
const ( Uvarint32TypeIDEncoding TypeIDEncoding = iota Uint32TypeIDEncoding Uint8TypeIDEncoding )
type Uint128 ¶
uint128
func (Uint128) DecimalString ¶
func (Uint128) MarshalBinary ¶
func (Uint128) MarshalJSON ¶
func (*Uint128) UnmarshalBinary ¶
func (*Uint128) UnmarshalJSON ¶
type Uint64 ¶
type Uint64 uint64
func (Uint64) MarshalBinary ¶
func (Uint64) MarshalJSON ¶
func (*Uint64) UnmarshalBinary ¶
func (*Uint64) UnmarshalJSON ¶
type UnmarshalerBinary ¶
type VariantDefinition ¶
type VariantDefinition struct {
// contains filtered or unexported fields
}
func NewVariantDefinition ¶
func NewVariantDefinition(typeIDEncoding TypeIDEncoding, types []VariantType) (out *VariantDefinition)
NewVariantDefinition creates a variant definition based on the *ordered* provided types. It's the ordering that defines the binary variant value just like in native `nodeos` C++ and in Smart Contract via the `std::variant` type. It's important to pass the entries in the right order!
This variant definition can now be passed to functions of `BaseVariant` to implement marshal/unmarshaling functionalities for binary & JSON.
func (*VariantDefinition) TypeID ¶
func (d *VariantDefinition) TypeID(name string) uint32
type VariantImplFactory ¶
type VariantImplFactory = func() interface{}
type VariantType ¶
type VariantType struct { Name string Type interface{} }
type Varint16 ¶
type Varint16 int16
func (Varint16) MarshalBinary ¶
func (*Varint16) UnmarshalBinary ¶
type Varint32 ¶
type Varint32 int32
func (Varint32) MarshalBinary ¶
func (*Varint32) UnmarshalBinary ¶
type Varuint16 ¶
type Varuint16 uint16