Documentation
¶
Index ¶
- Variables
- func DecodeMap[K comparable, V any](d *Decoder, decodeKey func(*Decoder) K, decodeValue func(*Decoder) V) map[K]V
- func DecodeSlice[T any](d *Decoder, decode func(*Decoder) T) []T
- func EncodeMap[K comparable, V any](e *Encoder, m map[K]V, encodeKey func(*Encoder, K), ...)
- func EncodeSlice[T any](e *Encoder, slice []T, encode func(*Encoder, T))
- func SizeBool() int
- func SizeByte() int
- func SizeBytes(v []byte) int
- func SizeFixedSlice[T any](slice []T, elemSize int) int
- func SizeFloat32() int
- func SizeFloat64() int
- func SizeInt(v int) int
- func SizeInt16() int
- func SizeInt32() int
- func SizeInt64() int
- func SizeMap[K comparable, V any](m map[K]V, kSizer func(K) int, vSizer func(V) int) int
- func SizeSlice[T any](slice []T, sizer func(T) int) int
- func SizeString(v string) int
- func SizeUint(v uint) int
- func SizeUint16() int
- func SizeUint32() int
- func SizeUint64() int
- type Decoder
- func (d *Decoder) Bool() bool
- func (d *Decoder) Byte() byte
- func (d *Decoder) BytesCopied() []byte
- func (d *Decoder) BytesCropped() []byte
- func (d *Decoder) Err() error
- func (d *Decoder) Float32() float32
- func (d *Decoder) Float64() float64
- func (d *Decoder) Int() int
- func (d *Decoder) Int16() int16
- func (d *Decoder) Int32() int32
- func (d *Decoder) Int64() int64
- func (d *Decoder) Offset() int
- func (d *Decoder) Remaining() int
- func (d *Decoder) SkipBool()
- func (d *Decoder) SkipByte()
- func (d *Decoder) SkipBytes()
- func (d *Decoder) SkipFloat32()
- func (d *Decoder) SkipFloat64()
- func (d *Decoder) SkipInt()
- func (d *Decoder) SkipInt16()
- func (d *Decoder) SkipInt32()
- func (d *Decoder) SkipInt64()
- func (d *Decoder) SkipMap()
- func (d *Decoder) SkipSlice()
- func (d *Decoder) SkipString()
- func (d *Decoder) SkipUint()
- func (d *Decoder) SkipUint16()
- func (d *Decoder) SkipUint32()
- func (d *Decoder) SkipUint64()
- func (d *Decoder) String() string
- func (d *Decoder) Uint() uint
- func (d *Decoder) Uint16() uint16
- func (d *Decoder) Uint32() uint32
- func (d *Decoder) Uint64() uint64
- func (d *Decoder) UnsafeString() string
- type Encoder
- func (e *Encoder) Bool(v bool)
- func (e *Encoder) Byte(v byte)
- func (e *Encoder) Bytes() []byte
- func (e *Encoder) BytesValue(v []byte)
- func (e *Encoder) Err() error
- func (e *Encoder) Float32(v float32)
- func (e *Encoder) Float64(v float64)
- func (e *Encoder) Int(v int)
- func (e *Encoder) Int16(v int16)
- func (e *Encoder) Int32(v int32)
- func (e *Encoder) Int64(v int64)
- func (e *Encoder) Len() int
- func (e *Encoder) String(v string)
- func (e *Encoder) Uint(v uint)
- func (e *Encoder) Uint16(v uint16)
- func (e *Encoder) Uint32(v uint32)
- func (e *Encoder) Uint64(v uint64)
- func (e *Encoder) UnsafeString(v string)
Constants ¶
This section is empty.
Variables ¶
var ErrBufTooSmall = errors.New("buffer too small")
ErrBufTooSmall reports that the provided buffer does not contain enough bytes.
var ErrOverflow = errors.New("varint overflows a 64-bit integer")
ErrOverflow reports that a varint exceeds the supported 64-bit range.
Functions ¶
func DecodeMap ¶
func DecodeMap[K comparable, V any](d *Decoder, decodeKey func(*Decoder) K, decodeValue func(*Decoder) V) map[K]V
DecodeMap reads a map using decodeKey and decodeValue for each pair.
func DecodeSlice ¶
DecodeSlice reads a slice using decode for each element.
func EncodeMap ¶
func EncodeMap[K comparable, V any](e *Encoder, m map[K]V, encodeKey func(*Encoder, K), encodeValue func(*Encoder, V))
EncodeMap writes a map header, key-value pairs, and sentinel terminator.
func EncodeSlice ¶
EncodeSlice writes a slice header, elements, and sentinel terminator.
func SizeFixedSlice ¶
SizeFixedSlice returns the encoded size of a slice with fixed-size elements.
func SizeInt16 ¶
func SizeInt16() int
SizeInt16 returns the encoded size of a 16-bit signed integer.
func SizeInt32 ¶
func SizeInt32() int
SizeInt32 returns the encoded size of a 32-bit signed integer.
func SizeInt64 ¶
func SizeInt64() int
SizeInt64 returns the encoded size of a 64-bit signed integer.
func SizeMap ¶
func SizeMap[K comparable, V any](m map[K]V, kSizer func(K) int, vSizer func(V) int) int
SizeMap returns the encoded size of a map.
func SizeString ¶
SizeString returns the encoded size of a length-prefixed string.
func SizeUint16 ¶
func SizeUint16() int
SizeUint16 returns the encoded size of a 16-bit unsigned integer.
func SizeUint32 ¶
func SizeUint32() int
SizeUint32 returns the encoded size of a 32-bit unsigned integer.
func SizeUint64 ¶
func SizeUint64() int
SizeUint64 returns the encoded size of a 64-bit unsigned integer.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads the compatibility wire format from a caller-owned buffer.
func NewDecoder ¶
NewDecoder creates a decoder that reads from buf starting at offset zero.
func (*Decoder) BytesCopied ¶
BytesCopied reads a length-prefixed byte slice into a newly allocated buffer.
func (*Decoder) BytesCropped ¶
BytesCropped reads a length-prefixed byte slice as a window into the source buffer.
func (*Decoder) SkipBytes ¶
func (d *Decoder) SkipBytes()
SkipBytes advances past a length-prefixed byte slice.
func (*Decoder) SkipFloat32 ¶
func (d *Decoder) SkipFloat32()
SkipFloat32 advances past a 32-bit float.
func (*Decoder) SkipFloat64 ¶
func (d *Decoder) SkipFloat64()
SkipFloat64 advances past a 64-bit float.
func (*Decoder) SkipInt16 ¶
func (d *Decoder) SkipInt16()
SkipInt16 advances past a 16-bit signed integer.
func (*Decoder) SkipInt32 ¶
func (d *Decoder) SkipInt32()
SkipInt32 advances past a 32-bit signed integer.
func (*Decoder) SkipInt64 ¶
func (d *Decoder) SkipInt64()
SkipInt64 advances past a 64-bit signed integer.
func (*Decoder) SkipMap ¶
func (d *Decoder) SkipMap()
SkipMap advances past a map payload and sentinel terminator.
func (*Decoder) SkipSlice ¶
func (d *Decoder) SkipSlice()
SkipSlice advances past a slice payload and sentinel terminator.
func (*Decoder) SkipString ¶
func (d *Decoder) SkipString()
SkipString advances past a length-prefixed string.
func (*Decoder) SkipUint ¶
func (d *Decoder) SkipUint()
SkipUint advances past an unsigned varint value.
func (*Decoder) SkipUint16 ¶
func (d *Decoder) SkipUint16()
SkipUint16 advances past a 16-bit unsigned integer.
func (*Decoder) SkipUint32 ¶
func (d *Decoder) SkipUint32()
SkipUint32 advances past a 32-bit unsigned integer.
func (*Decoder) SkipUint64 ¶
func (d *Decoder) SkipUint64()
SkipUint64 advances past a 64-bit unsigned integer.
func (*Decoder) UnsafeString ¶
UnsafeString reads a length-prefixed string using the package's zero-copy string conversion.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes the compatibility wire format into a caller-owned buffer.
func NewDynamicEncoder ¶
NewDynamicEncoder creates an encoder backed by an internal growable buffer.
func NewEncoder ¶
NewEncoder creates an encoder that writes into buf starting at offset zero.
func (*Encoder) BytesValue ¶
BytesValue writes a length-prefixed byte slice.
func (*Encoder) UnsafeString ¶
UnsafeString writes a length-prefixed string using the package's zero-copy string conversion.