cser

package
v0.0.0-...-9aa21c9 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonCanonicalEncoding = errors.New("non canonical encoding")
	ErrMalformedEncoding    = errors.New("malformed encoding")
)

Functions

func MarshalBinaryAdapter

func MarshalBinaryAdapter(marshalCser func(*Writer) error) ([]byte, error)

func PaddedBytes

func PaddedBytes(b []byte, n int) []byte

PaddedBytes returns a slice with length of the slice is at least n bytes.

func UnmarshalBinaryAdapter

func UnmarshalBinaryAdapter(raw []byte, unmarshalCser func(reader *Reader) error) (err error)

Types

type Reader

type Reader struct {
	BitsR  *bits.Reader
	BytesR *fast.Reader
}

func (*Reader) BigInt

func (r *Reader) BigInt() *big.Int

func (*Reader) Bool

func (r *Reader) Bool() bool

func (*Reader) FixedBytes

func (r *Reader) FixedBytes(v []byte)

func (*Reader) I64

func (r *Reader) I64() int64

func (*Reader) SliceBytes

func (r *Reader) SliceBytes() []byte

func (*Reader) U16

func (r *Reader) U16() uint16

func (*Reader) U32

func (r *Reader) U32() uint32

func (*Reader) U56

func (r *Reader) U56() uint64

func (*Reader) U64

func (r *Reader) U64() uint64

func (*Reader) U8

func (r *Reader) U8() uint8

func (*Reader) VarUint

func (r *Reader) VarUint() uint64

type Writer

type Writer struct {
	BitsW  *bits.Writer
	BytesW *fast.Writer
}

func NewWriter

func NewWriter() *Writer

func (*Writer) BigInt

func (w *Writer) BigInt(v *big.Int)

func (*Writer) Bool

func (w *Writer) Bool(v bool)

func (*Writer) FixedBytes

func (w *Writer) FixedBytes(v []byte)

func (*Writer) I64

func (w *Writer) I64(v int64)

func (*Writer) SliceBytes

func (w *Writer) SliceBytes(v []byte)

func (*Writer) U16

func (w *Writer) U16(v uint16)

func (*Writer) U32

func (w *Writer) U32(v uint32)

func (*Writer) U56

func (w *Writer) U56(v uint64)

func (*Writer) U64

func (w *Writer) U64(v uint64)

func (*Writer) U8

func (w *Writer) U8(v uint8)

func (*Writer) VarUint

func (w *Writer) VarUint(v uint64)

Jump to

Keyboard shortcuts

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