Documentation ¶
Overview ¶
Package codec implements serialization and deserialization defined in LIP-0027 and LIP-0064 and lisk32 representation of address defined in LIP-0018.
Index ¶
- Variables
- func BytesToLisk32[T ~byte](val []T) (string, error)
- func HexArrayToBytesArray(val []Hex) [][]byte
- func Lisk32ArrayToBytesArray(val []Lisk32) [][]byte
- func Lisk32ToBytes(val string) ([]byte, error)
- func ValidateLisk32(val string) error
- type Decodable
- type DecodableReader
- type Encodable
- type EncodeDecodable
- type Hex
- type Lisk32
- type Reader
- func (r *Reader) HasUnreadBytes() bool
- func (r *Reader) ReadBool(fieldNumber int, strict bool) (bool, error)
- func (r *Reader) ReadBools(fieldNumber int) ([]bool, error)
- func (r *Reader) ReadBytes(fieldNumber int, strict bool) ([]byte, error)
- func (r *Reader) ReadBytesArray(fieldNumber int) ([][]byte, error)
- func (r *Reader) ReadDecodable(fieldNumber int, creator func() DecodableReader, strict bool) (DecodableReader, error)
- func (r *Reader) ReadDecodables(fieldNumber int, creator func() DecodableReader) ([]interface{}, error)
- func (r *Reader) ReadInt(fieldNumber int, strict bool) (int64, error)
- func (r *Reader) ReadInt32(fieldNumber int, strict bool) (int32, error)
- func (r *Reader) ReadInts(fieldNumber int) ([]int64, error)
- func (r *Reader) ReadString(fieldNumber int, strict bool) (string, error)
- func (r *Reader) ReadStrings(fieldNumber int) ([]string, error)
- func (r *Reader) ReadUInt(fieldNumber int, strict bool) (uint64, error)
- func (r *Reader) ReadUInt32(fieldNumber int, strict bool) (uint32, error)
- func (r *Reader) ReadUInt32s(fieldNumber int) ([]uint32, error)
- func (r *Reader) ReadUInts(fieldNumber int) ([]uint64, error)
- type UInt64Str
- type Writer
- func (w *Writer) Result() []byte
- func (w *Writer) Size() int
- func (w *Writer) WriteBool(fieldNumber int, data bool)
- func (w *Writer) WriteBools(fieldNumber int, data []bool)
- func (w *Writer) WriteBytes(fieldNumber int, data []byte)
- func (w *Writer) WriteBytesArray(fieldNumber int, data [][]byte)
- func (w *Writer) WriteEncodable(fieldNumber int, data Encodable)
- func (w *Writer) WriteInt(fieldNumber int, data int64)
- func (w *Writer) WriteInt32(fieldNumber int, data int32)
- func (w *Writer) WriteInt32s(fieldNumber int, data []int32)
- func (w *Writer) WriteInts(fieldNumber int, data []int64)
- func (w *Writer) WriteString(fieldNumber int, data string)
- func (w *Writer) WriteStrings(fieldNumber int, data []string)
- func (w *Writer) WriteUInt(fieldNumber int, data uint64)
- func (w *Writer) WriteUInt32(fieldNumber int, data uint32)
- func (w *Writer) WriteUInt32s(fieldNumber int, data []uint32)
- func (w *Writer) WriteUInts(fieldNumber int, data []uint64)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidData represents general invalid data. ErrInvalidData = errors.New("invalid data") // ErrOutOfRange represents logic accessing data in out of range. ErrOutOfRange = errors.New("out of range") // ErrNoTerminate represents invalid protobuf format. ErrNoTerminate = errors.New("no terminationg bit found") // ErrUnexpectedFieldNumber represents protobuf field number not matching expected value. ErrUnexpectedFieldNumber = errors.New("unexpected field number found") // ErrFieldNumberNotFound represents protobuf field number not matching expected value. ErrFieldNumberNotFound = errors.New("expected field number does not exist") // ErrUnreadBytes represents extra bytes not read. ErrUnreadBytes = errors.New("unread bytes exist") // ErrUnnecessaryLeadingBytes represents error for which varint has unnecessary 0x80 byte at the beginning. ErrUnnecessaryLeadingBytes = errors.New("unnecessary leading bytes for varint found") )
Functions ¶
func BytesToLisk32 ¶
func HexArrayToBytesArray ¶
func Lisk32ArrayToBytesArray ¶
func Lisk32ToBytes ¶
func ValidateLisk32 ¶
Types ¶
type Decodable ¶
Decodable is interface for struct which is decodable All generated struct code should have this method.
type DecodableReader ¶
DecodableReader is interface for struct which is decodable All generated struct code should have this method.
type Encodable ¶
type Encodable interface {
Encode() []byte
}
Encodable is interface for struct which is encodable All generated struct code should have this method.
type EncodeDecodable ¶
type EncodeDecodable interface { Encodable Decodable DecodableReader }
EncodeDecodable can encode and decode.
type Hex ¶
type Hex []byte
func BytesArrayToHexArray ¶
func (Hex) MarshalJSON ¶
func (*Hex) UnmarshalJSON ¶
type Lisk32 ¶
type Lisk32 []byte
func BytesArrayToLisk32Array ¶
func (Lisk32) MarshalJSON ¶
func (*Lisk32) UnmarshalJSON ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is responsible for reading data in protobuf protocol.
func (*Reader) HasUnreadBytes ¶
func (*Reader) ReadBytesArray ¶
ReadBytesArray reads [][]byte if the field number matches.
func (*Reader) ReadDecodable ¶
func (r *Reader) ReadDecodable(fieldNumber int, creator func() DecodableReader, strict bool) (DecodableReader, error)
ReadDecodable reads struct if the field number matches.
func (*Reader) ReadDecodables ¶
func (r *Reader) ReadDecodables(fieldNumber int, creator func() DecodableReader) ([]interface{}, error)
ReadDecodables reads array of struct if the field number matches.
func (*Reader) ReadString ¶
ReadString reads string if the field number matches.
func (*Reader) ReadStrings ¶
ReadStrings reads []string if the field number matches.
func (*Reader) ReadUInt32 ¶
ReadUInt32 reads uint32 if the field number matches.
func (*Reader) ReadUInt32s ¶
ReadUInt32s reads []uint32 if the field number matches.
type UInt64Str ¶
type UInt64Str uint64
UInt64Str type for marshal and unmarshal uint64 json string.
func (UInt64Str) MarshalJSON ¶
func (*UInt64Str) UnmarshalJSON ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is responsible for writing data in protobuf protocol.
func (*Writer) WriteBools ¶
WriteBools writes booleans to result.
func (*Writer) WriteBytes ¶
WriteBytes writes a bytes to result.
func (*Writer) WriteBytesArray ¶
WriteBytesArray writes bytes array to result.
func (*Writer) WriteEncodable ¶
WriteEncodable writes encodable struct to result.
func (*Writer) WriteInt32 ¶
WriteInt32 writes int to result.
func (*Writer) WriteInt32s ¶
WriteInt32s writes int to result.
func (*Writer) WriteString ¶
WriteString writes a string to result.
func (*Writer) WriteStrings ¶
WriteStrings writes strings to result.
func (*Writer) WriteUInt32 ¶
WriteUInt32 writes uint to result.
func (*Writer) WriteUInt32s ¶
WriteUInt32s writes uint to result.
func (*Writer) WriteUInts ¶
WriteUInts writes uint to result.
Directories ¶
Path | Synopsis |
---|---|
gen generates encoding/decoding codes for struct using "fieldNumber" tag.
|
gen generates encoding/decoding codes for struct using "fieldNumber" tag. |
internal
Code generated for package internal by go-bindata DO NOT EDIT.
|
Code generated for package internal by go-bindata DO NOT EDIT. |
internal
|
|
codec_test
Package codec_test is a test package for codec.
|
Package codec_test is a test package for codec. |