Documentation ¶
Index ¶
- func Decode(in []byte, t interface{}) (interface{}, error)
- func DecodeCustom(in []byte, t interface{}) error
- func DecodePtr(in []byte, t interface{}) error
- func Encode(in interface{}) ([]byte, error)
- func EncodeCustom(in interface{}) ([]byte, error)
- type Decoder
- func (sd *Decoder) Decode(t interface{}) (out interface{}, err error)
- func (sd *Decoder) DecodeArray(t interface{}) (interface{}, error)
- func (sd *Decoder) DecodeBigInt() (output *big.Int, err error)
- func (sd *Decoder) DecodeBigIntArray() ([]*big.Int, error)
- func (sd *Decoder) DecodeBool() (bool, error)
- func (sd *Decoder) DecodeBoolArray() ([]bool, error)
- func (sd *Decoder) DecodeByteArray() (o []byte, err error)
- func (sd *Decoder) DecodeCustom(t interface{}) (interface{}, error)
- func (sd *Decoder) DecodeFixedWidthInt(t interface{}) (o interface{}, err error)
- func (sd *Decoder) DecodeIntArray() ([]int, error)
- func (sd *Decoder) DecodeInteger() (_ int64, err error)
- func (sd *Decoder) DecodeInterface(t interface{}) (interface{}, error)
- func (sd *Decoder) DecodePtr(t interface{}) (err error)
- func (sd *Decoder) DecodePtrBigInt(output *big.Int) (err error)
- func (sd *Decoder) DecodePtrBigIntArray(output interface{}) error
- func (sd *Decoder) DecodePtrBool(output interface{}) error
- func (sd *Decoder) DecodePtrBoolArray(output interface{}) error
- func (sd *Decoder) DecodePtrByteArray(output interface{}) error
- func (sd *Decoder) DecodePtrFixedWidthInt(t interface{}) (err error)
- func (sd *Decoder) DecodePtrIntArray(t interface{}) error
- func (sd *Decoder) DecodeSlice(t interface{}) (interface{}, error)
- func (sd *Decoder) DecodeStringArray() ([]string, error)
- func (sd *Decoder) DecodeTuple(t interface{}) (interface{}, error)
- func (sd *Decoder) DecodeUnsignedInteger() (o uint64, err error)
- func (sd *Decoder) ReadByte() (byte, error)
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCustom ¶
DecodeCustom check if interface has method Decode, if so use that, otherwise use regular scale decoding
func EncodeCustom ¶
EncodeCustom checks if interface has method Encode, if so use that, otherwise use regular scale encoding
Types ¶
type Decoder ¶
Decoder is a wrapping around io.Reader
func (*Decoder) Decode ¶
Decode is the high level function wrapping the specific type decoding functions
func (*Decoder) DecodeArray ¶
DecodeArray decodes a fixed-length array
func (*Decoder) DecodeBigInt ¶
DecodeBigInt decodes a SCALE encoded byte array into a *big.Int Works for all integers, including ints > 2**64
func (*Decoder) DecodeBigIntArray ¶
DecodeBigIntArray decodes a byte array to an array of *big.Ints
func (*Decoder) DecodeBool ¶
DecodeBool accepts a byte array representing a SCALE encoded bool and performs SCALE decoding of the bool then returns it. if invalid, return false and an error
func (*Decoder) DecodeBoolArray ¶
DecodeBoolArray decodes a byte array to an array of bools
func (*Decoder) DecodeByteArray ¶
DecodeByteArray accepts a byte array representing a SCALE encoded byte array and performs SCALE decoding of the byte array if the encoding is valid, it then returns the decoded byte array, the total number of input bytes decoded, and nil otherwise, it returns nil, 0, and error
func (*Decoder) DecodeCustom ¶
DecodeCustom check if interface has method Decode(io.Reader), if so use that, otherwise use regular scale decoding
func (*Decoder) DecodeFixedWidthInt ¶
DecodeFixedWidthInt decodes integers < 2**32 by reading the bytes in little endian
func (*Decoder) DecodeIntArray ¶
DecodeIntArray decodes a byte array to an array of ints
func (*Decoder) DecodeInteger ¶
DecodeInteger accepts a byte array representing a SCALE encoded integer and performs SCALE decoding of the int if the encoding is valid, it then returns (o, bytesDecoded, err) where o is the decoded integer, bytesDecoded is the number of input bytes decoded, and err is nil otherwise, it returns 0, 0, and error
func (*Decoder) DecodeInterface ¶
DecodeInterface will decode to interface
func (*Decoder) DecodePtr ¶
DecodePtr is the high level function wrapping the specific type decoding functions The results of decode are written to t interface by reference (instead of returning
value as Decode does)
func (*Decoder) DecodePtrBigInt ¶
DecodePtrBigInt decodes a SCALE encoded byte array into a *big.Int
Changes the value of output to decoded value
Works for all integers, including ints > 2**64
func (*Decoder) DecodePtrBigIntArray ¶
DecodePtrBigIntArray decodes a byte array to an array of *big.Ints
writes value to output by reference
func (*Decoder) DecodePtrBool ¶
DecodePtrBool accepts a byte array representing a SCALE encoded bool and performs SCALE decoding of the bool then writes the result to output via reference. if invalid, false and an error
func (*Decoder) DecodePtrBoolArray ¶
DecodePtrBoolArray decodes a byte array to an array of bools that is written to output by reference
func (*Decoder) DecodePtrByteArray ¶
DecodePtrByteArray accepts a byte array representing a SCALE encoded byte array and performs SCALE decoding of the byte array
func (*Decoder) DecodePtrFixedWidthInt ¶
DecodePtrFixedWidthInt decodes integers < 2**32 by reading the bytes in little endian
and writes results by reference t
func (*Decoder) DecodePtrIntArray ¶
DecodePtrIntArray decodes a byte array to an array of ints
func (*Decoder) DecodeSlice ¶ added in v0.2.0
DecodeSlice will decode a slice
func (*Decoder) DecodeStringArray ¶
DecodeStringArray will decode to string array
func (*Decoder) DecodeTuple ¶
DecodeTuple accepts a byte array representing the SCALE encoded tuple and an interface. This interface should be a pointer to a struct which the encoded tuple should be marshaled into. If it is a valid encoding for the struct, it returns the decoded struct, otherwise error, Note that we return the same interface that was passed to this function; this is because we are writing directly to the struct that is passed in, using reflect to get each of the fields.
func (*Decoder) DecodeUnsignedInteger ¶
DecodeUnsignedInteger will decode unsigned integer
type Encoder ¶
Encoder is a wrapping around io.Writer
func (*Encoder) Encode ¶
Encode is the top-level function which performs SCALE encoding of b which may be of type []byte, int16, int32, int64, or bool
func (*Encoder) EncodeCustom ¶ added in v0.2.0
EncodeCustom checks if interface has method Encode, if so use that, otherwise return error