serialization

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(value interface{}) ([]byte, error)

Marshal returns the bytes representation of v.

func MustMarshal

func MustMarshal(value interface{}) []byte

MustMarshal is the panic-on-fail version of Marshal

func MustUnmarshal

func MustUnmarshal(src []byte, dest interface{})

func Unmarshal

func Unmarshal(src []byte, dest interface{}) error

Types

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (dec *Decoder) Decode(v interface{}) (int, error)

func (*Decoder) DecodeArray

func (dec *Decoder) DecodeArray(v reflect.Value) (int, error)

DecodeArray decodes array

func (*Decoder) DecodeBigNumber

func (dec *Decoder) DecodeBigNumber(v reflect.Value, expectedLength int) (int, error)

func (*Decoder) DecodeBool

func (dec *Decoder) DecodeBool() (bool, int, error)

DecodeBool decodes bool. Returns the number of bytes read

func (*Decoder) DecodeByte

func (dec *Decoder) DecodeByte() (byte, int, error)

DecodeByte decodes byte

func (*Decoder) DecodeFixedArray

func (dec *Decoder) DecodeFixedArray(v reflect.Value) (int, error)

DecodeFixedArray decodes array for which the size is determined when the array is created

func (*Decoder) DecodeFixedByteArray

func (dec *Decoder) DecodeFixedByteArray(length int) ([]byte, int, error)

func (*Decoder) DecodeInt32

func (dec *Decoder) DecodeInt32() (int32, int, error)

DecodeInt32 decodes int32

func (*Decoder) DecodeInt64

func (dec *Decoder) DecodeInt64() (int64, int, error)

DecodeInt64 decodes int64

func (*Decoder) DecodeMap

func (dec *Decoder) DecodeMap(v reflect.Value) (int, error)

DecodeMap decodes map

func (*Decoder) DecodeOptional

func (dec *Decoder) DecodeOptional(v reflect.Value) (int, error)

func (*Decoder) DecodeResult

func (dec *Decoder) DecodeResult(v reflect.Value) (int, error)

func (*Decoder) DecodeString

func (dec *Decoder) DecodeString() (string, int, error)

DecodeString decodes string

func (*Decoder) DecodeStruct

func (dec *Decoder) DecodeStruct(v reflect.Value) (int, error)

DecodeStruct decodes struct

func (*Decoder) DecodeTuple

func (dec *Decoder) DecodeTuple(v reflect.Value) (int, error)

DecodeTuple decodes tuple

func (*Decoder) DecodeU128

func (dec *Decoder) DecodeU128(v reflect.Value) (int, error)

DecodeU128 decodes uint128

func (*Decoder) DecodeU256

func (dec *Decoder) DecodeU256(v reflect.Value) (int, error)

DecodeU256 decodes uint256

func (*Decoder) DecodeU512

func (dec *Decoder) DecodeU512(v reflect.Value) (int, error)

DecodeU512 decodes decodes uint512

func (*Decoder) DecodeUInt32

func (dec *Decoder) DecodeUInt32() (uint32, int, error)

DecodeUInt32 decodes uint32

func (*Decoder) DecodeUInt64

func (dec *Decoder) DecodeUInt64() (uint64, int, error)

DecodeUInt64 decodes uint64

func (*Decoder) DecodeUnion

func (dec *Decoder) DecodeUnion(v reflect.Value, discriminant byte) (int, error)

DecodeUnion decodes union

func (*Decoder) DecodeUnmarshaler

func (dec *Decoder) DecodeUnmarshaler(v reflect.Value) (int, error)

type Encoder

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

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (enc *Encoder) Encode(v interface{}) (int, error)

func (*Encoder) EncodeArray

func (enc *Encoder) EncodeArray(v reflect.Value) (int, error)

EncodeArray encodes array

func (*Encoder) EncodeBigInt

func (enc *Encoder) EncodeBigInt(v big.Int) (int, error)

EncodeBigInt encodes big number

func (*Encoder) EncodeBool

func (enc *Encoder) EncodeBool(v bool) (int, error)

EncodeBool encodes bool value

func (*Encoder) EncodeByte

func (enc *Encoder) EncodeByte(v byte) (int, error)

EncodeByte encodes byte value

func (*Encoder) EncodeByteArray

func (enc *Encoder) EncodeByteArray(v []byte) (int, error)

EncodeByteArray encodes byte array

func (*Encoder) EncodeFixedArray

func (enc *Encoder) EncodeFixedArray(v reflect.Value) (int, error)

EncodeFixedArray encodes array with fixed size

func (*Encoder) EncodeFixedByteArray

func (enc *Encoder) EncodeFixedByteArray(v []byte) (int, error)

EncodeFixedByteArray encodes byte array with fixed size

func (*Encoder) EncodeInt32

func (enc *Encoder) EncodeInt32(v int32) (int, error)

EncodeInt32 encodes int32 value

func (*Encoder) EncodeInt64

func (enc *Encoder) EncodeInt64(v int64) (int, error)

EncodeInt64 encodes int64 value

func (*Encoder) EncodeInterface

func (enc *Encoder) EncodeInterface(v reflect.Value) (int, error)

EncodeInterface encodes interface

func (*Encoder) EncodeMap

func (enc *Encoder) EncodeMap(v reflect.Value) (int, error)

EncodeMap encodes map

func (*Encoder) EncodeMarshaler

func (enc *Encoder) EncodeMarshaler(v reflect.Value) (int, error)

func (*Encoder) EncodeOptional

func (enc *Encoder) EncodeOptional(v reflect.Value) (int, error)

func (*Encoder) EncodeResult

func (enc *Encoder) EncodeResult(v reflect.Value) (int, error)

func (*Encoder) EncodeString

func (enc *Encoder) EncodeString(v string) (int, error)

EncodeString encodes string value

func (*Encoder) EncodeStruct

func (enc *Encoder) EncodeStruct(v reflect.Value) (int, error)

EncodeStruct encodes struct

func (*Encoder) EncodeTuple

func (enc *Encoder) EncodeTuple(v reflect.Value) (int, error)

EncodeTuple encodes tuple

func (*Encoder) EncodeUInt32

func (enc *Encoder) EncodeUInt32(v uint32) (int, error)

EncodeUIn32 encodes uint32 value

func (*Encoder) EncodeUInt64

func (enc *Encoder) EncodeUInt64(v uint64) (int, error)

EncodeUIn64 encodes uint64 value

func (*Encoder) EncodeUnion

func (enc *Encoder) EncodeUnion(v reflect.Value) (int, error)

EncodeUnion encodes union

type Marshaler

type Marshaler interface {
	Marshal(w io.Writer) (int, error)
}

type Result

type Result interface {
	ResultFieldName() string
	SuccessFieldName() string
	ErrorFieldName() string
}

type Tuple

type Tuple interface {
	TupleFields() []string
}

type U128

type U128 struct {
	big.Int
}

type U256

type U256 struct {
	big.Int
}

type U512

type U512 struct {
	big.Int
}

type Union

type Union interface {
	ArmForSwitch(byte) (string, bool)
	SwitchFieldName() string
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(r io.Reader) (int, error)
}

Jump to

Keyboard shortcuts

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