encoding

package
v0.0.0-...-a0ddc14 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCertletErrorBase   = errors.New("certlet: base error")
	ErrDataTypeNotSupport = errors.New("certlet: data type not support")
)

Functions

func DecodeUnifiedVarInt

func DecodeUnifiedVarInt(buffer []byte, offset int) (int64, int)

func DecodeUnifiedVarUint

func DecodeUnifiedVarUint(buffer []byte, offset int) (uint64, int)

func DecodeVarInt

func DecodeVarInt(buffer []byte, offset int) (int64, int)

func DecodeVarUint

func DecodeVarUint(buffer []byte, offset int) (uint64, int)

func EncodeUnifiedVarInt

func EncodeUnifiedVarInt(value int64, buffer []byte, offset int) int

func EncodeUnifiedVarIntSize

func EncodeUnifiedVarIntSize(value int64) int

func EncodeUnifiedVarUint

func EncodeUnifiedVarUint(value uint64, buffer []byte, offset int) int

func EncodeUnifiedVarUintSize

func EncodeUnifiedVarUintSize(value uint64) int

func EncodeVarInt

func EncodeVarInt(value int64, buffer []byte, offset int) int

func EncodeVarIntSize

func EncodeVarIntSize(value int64) int

func EncodeVarUint

func EncodeVarUint(value uint64, buffer []byte, offset int) int

func EncodeVarUintSize

func EncodeVarUintSize(value uint64) int

Types

type Decoder

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

func NewDecoder

func NewDecoder(buffer []byte, offset int) *Decoder

func (*Decoder) CheckBufferSize

func (d *Decoder) CheckBufferSize(size int) bool

func (*Decoder) DecodeBinary

func (d *Decoder) DecodeBinary() ([]byte, int)

func (*Decoder) DecodeByte

func (d *Decoder) DecodeByte() (uint8, int)

func (*Decoder) DecodeRawBinary

func (d *Decoder) DecodeRawBinary(size int) ([]byte, int)

func (*Decoder) DecodeUintLE

func (d *Decoder) DecodeUintLE(size int) (uint64, int)

func (*Decoder) DecodeVarInt

func (d *Decoder) DecodeVarInt() (int64, int)

func (*Decoder) DecodeVarUint

func (d *Decoder) DecodeVarUint() (uint64, int)

func (*Decoder) DecodeWireID

func (d *Decoder) DecodeWireID() (WireID, int)

func (*Decoder) EOF

func (d *Decoder) EOF() bool

func (*Decoder) SetOffset

func (d *Decoder) SetOffset(offset int)

type Encoder

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

func NewEncoder

func NewEncoder(buffer []byte, offset int) *Encoder

func (*Encoder) CheckBufferSize

func (e *Encoder) CheckBufferSize(size int) bool

func (*Encoder) EncodeBinary

func (e *Encoder) EncodeBinary(value []byte) int

func (*Encoder) EncodeByte

func (e *Encoder) EncodeByte(value uint8) int

func (*Encoder) EncodeFloatLE

func (e *Encoder) EncodeFloatLE(value float64, size int) int

func (*Encoder) EncodeIntLE

func (e *Encoder) EncodeIntLE(value int64, size int) int

func (*Encoder) EncodeRawBinary

func (e *Encoder) EncodeRawBinary(value []byte) int

func (*Encoder) EncodeUintLE

func (e *Encoder) EncodeUintLE(value uint64, size int) int

func (*Encoder) EncodeVarInt

func (e *Encoder) EncodeVarInt(value int64) int

func (*Encoder) EncodeVarUint

func (e *Encoder) EncodeVarUint(value uint64) int

type Field

type Field struct {
	Repeated bool
	HasName  bool
	// contains filtered or unexported fields
}

func NewBlob

func NewBlob(fieldID uint64, value any) *Field

func NewField

func NewField(fieldID uint64, value any) *Field

func NewFieldEOF

func NewFieldEOF() *Field

func NewFixedLengthField

func NewFixedLengthField(fieldID uint64, value any) *Field

func NewVarint

func NewVarint(fieldID uint64, value any) *Field

func ParseField

func ParseField(buffer []byte, offset int) (*Field, int)

func (*Field) Blob

func (f *Field) Blob() []byte

func (*Field) Bytes

func (f *Field) Bytes() []byte

func (*Field) FieldID

func (f *Field) FieldID() uint64

func (*Field) Int

func (f *Field) Int() int64

func (*Field) Name

func (f *Field) Name() string

func (*Field) ReadFrom

func (f *Field) ReadFrom(buffer []byte, offset int) int

func (*Field) String

func (f *Field) String() string

func (*Field) Uint

func (f *Field) Uint() uint64

func (*Field) WireID

func (f *Field) WireID() WireID

func (*Field) WithName

func (f *Field) WithName(name string) *Field

func (*Field) WriteTo

func (f *Field) WriteTo(buffer []byte, offset int) int

type FixedLengthType

type FixedLengthType uint8
const (
	FixedLengthTypeNull      FixedLengthType = 0x00
	FixedLengthTypeInteger   FixedLengthType = 0x40
	FixedLengthTypeFloat     FixedLengthType = 0x80
	FixedLengthTypeTimestamp FixedLengthType = 0xc0
)

type MemoryType

type MemoryType int
const (
	MemoryTypeUint MemoryType = iota
	MemoryTypeInt
	MemoryTypeBigInt
	MemoryTypeFloat
	MemoryTypeBlob
)

type WireID

type WireID uint64

func (WireID) AsUint

func (i WireID) AsUint() uint64

func (WireID) FieldID

func (i WireID) FieldID() uint64

func (WireID) HasName

func (i WireID) HasName() bool

func (WireID) Repeated

func (i WireID) Repeated() bool

func (WireID) WireType

func (i WireID) WireType() WireType

type WireType

type WireType uint8
const (
	WireTypeFixedLength    WireType = 0
	WireTypeVariableLength WireType = 1
	WireTypeBlob           WireType = 2
	WireTypeInnerStructure WireType = 3

	WireRepeatedFlag = 0x40
	WireHasNameFlag  = 0x80
)

func (WireType) String

func (t WireType) String() string

Jump to

Keyboard shortcuts

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