Documentation
¶
Overview ¶
Package encoding provides functions to marshal and unmarshal data types.
Index ¶
- Variables
- func MarshalBool(n int, b []byte, v bool) int
- func MarshalByte(n int, b []byte, byt byte) int
- func MarshalBytes(n int, b []byte, bs []byte) int
- func MarshalFloat32(n int, b []byte, v float32) int
- func MarshalFloat64(n int, b []byte, v float64) int
- func MarshalInt(n int, b []byte, sv int) int
- func MarshalInt16(n int, b []byte, v int16) int
- func MarshalInt32(n int, b []byte, v int32) int
- func MarshalInt64(n int, b []byte, v int64) int
- func MarshalMap[K comparable, V any](n int, b []byte, m map[K]V, kMarshaler MarshalFunc[K], ...) int
- func MarshalSlice[T any](n int, b []byte, slice []T, marshaler MarshalFunc[T]) int
- func MarshalString(n int, b []byte, str string) int
- func MarshalUint(n int, b []byte, v uint) int
- func MarshalUint16(n int, b []byte, v uint16) int
- func MarshalUint32(n int, b []byte, v uint32) int
- func MarshalUint64(n int, b []byte, v uint64) int
- func SizeBool() int
- func SizeByte() int
- func SizeBytes(bs []byte) int
- func SizeFloat32() int
- func SizeFloat64() int
- func SizeInt(sv int) int
- func SizeInt16() int
- func SizeInt32() int
- func SizeInt64() int
- func SizeMap[K comparable, V any](m map[K]V, kSizer interface{}, vSizer interface{}) (s int)
- func SizeSlice[T any](slice []T, sizer interface{}) (s int)
- func SizeString(str string) int
- func SizeUint(v uint) int
- func SizeUint16() int
- func SizeUint32() int
- func SizeUint64() int
- func SkipBool(n int, b []byte) (int, error)
- func SkipByte(n int, b []byte) (int, error)
- func SkipBytes(n int, b []byte) (int, error)
- func SkipFloat32(n int, b []byte) (int, error)
- func SkipFloat64(n int, b []byte) (int, error)
- func SkipInt16(n int, b []byte) (int, error)
- func SkipInt32(n int, b []byte) (int, error)
- func SkipInt64(n int, b []byte) (int, error)
- func SkipMap(n int, b []byte) (int, error)
- func SkipSlice(n int, b []byte) (int, error)
- func SkipString(n int, b []byte) (int, error)
- func SkipUint16(n int, b []byte) (int, error)
- func SkipUint32(n int, b []byte) (int, error)
- func SkipUint64(n int, b []byte) (int, error)
- func SkipVarint(n int, buf []byte) (int, error)
- func UnmarshalBool(n int, b []byte) (int, bool, error)
- func UnmarshalByte(n int, b []byte) (int, byte, error)
- func UnmarshalBytes(n int, b []byte) (int, []byte, error)
- func UnmarshalFloat32(n int, b []byte) (int, float32, error)
- func UnmarshalFloat64(n int, b []byte) (int, float64, error)
- func UnmarshalInt(n int, buf []byte) (int, int, error)
- func UnmarshalInt16(n int, b []byte) (int, int16, error)
- func UnmarshalInt32(n int, b []byte) (int, int32, error)
- func UnmarshalInt64(n int, b []byte) (int, int64, error)
- func UnmarshalMap[K comparable, V any](n int, b []byte, kUnmarshaler interface{}, vUnmarshaler interface{}) (int, map[K]V, error)
- func UnmarshalSlice[T any](n int, b []byte, unmarshaler interface{}) (int, []T, error)
- func UnmarshalString(n int, b []byte) (int, string, error)
- func UnmarshalUint(n int, buf []byte) (int, uint, error)
- func UnmarshalUint16(n int, b []byte) (int, uint16, error)
- func UnmarshalUint32(n int, b []byte) (int, uint32, error)
- func UnmarshalUint64(n int, b []byte) (int, uint64, error)
- type MarshalFunc
- type Signed
- type StringHeader
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
var ErrBufTooSmall = errors.New("buffer too small")
ErrBufTooSmall is returned when the buffer is too small to read/write.
var ErrOverflow = errors.New("varint overflows a 64-bit integer")
ErrOverflow is returned when a varint overflows a 64-bit integer.
Functions ¶
func MarshalBool ¶
MarshalBool marshals a bool into the buffer.
func MarshalByte ¶
MarshalByte marshals a byte into the buffer.
func MarshalBytes ¶
MarshalBytes marshals a byte slice into the buffer.
func MarshalFloat32 ¶
MarshalFloat32 marshals a float32 into the buffer.
func MarshalFloat64 ¶
MarshalFloat64 marshals a float64 into the buffer.
func MarshalInt ¶
MarshalInt marshals a signed integer into the buffer.
func MarshalInt16 ¶
MarshalInt16 marshals an int16 into the buffer.
func MarshalInt32 ¶
MarshalInt32 marshals an int32 into the buffer.
func MarshalInt64 ¶
MarshalInt64 marshals an int64 into the buffer.
func MarshalMap ¶
func MarshalMap[K comparable, V any](n int, b []byte, m map[K]V, kMarshaler MarshalFunc[K], vMarshaler MarshalFunc[V]) int
MarshalMap marshals a map into the buffer.
func MarshalSlice ¶
func MarshalSlice[T any](n int, b []byte, slice []T, marshaler MarshalFunc[T]) int
MarshalSlice marshals a slice into the buffer.
func MarshalString ¶
MarshalString marshals a string into the buffer.
func MarshalUint ¶
MarshalUint marshals an unsigned integer into the buffer.
func MarshalUint16 ¶
MarshalUint16 marshals a uint16 into the buffer.
func MarshalUint32 ¶
MarshalUint32 marshals a uint32 into the buffer.
func MarshalUint64 ¶
MarshalUint64 marshals a uint64 into the buffer.
func SizeFloat32 ¶
func SizeFloat32() int
SizeFloat32 returns the bytes needed to marshal a float32.
func SizeFloat64 ¶
func SizeFloat64() int
SizeFloat64 returns the bytes needed to marshal a float64.
func SizeMap ¶
func SizeMap[K comparable, V any](m map[K]V, kSizer interface{}, vSizer interface{}) (s int)
SizeMap returns the bytes needed to marshal a map.
func SizeString ¶
SizeString returns the bytes needed to marshal a string.
func SkipFloat32 ¶
SkipFloat32 skips a float32 in the buffer.
func SkipFloat64 ¶
SkipFloat64 skips a float64 in the buffer.
func SkipString ¶
SkipString skips a string in the buffer.
func SkipUint16 ¶
SkipUint16 skips a uint16 in the buffer.
func SkipUint32 ¶
SkipUint32 skips a uint32 in the buffer.
func SkipUint64 ¶
SkipUint64 skips a uint64 in the buffer.
func SkipVarint ¶
SkipVarint skips a varint in the buffer.
func UnmarshalBool ¶
UnmarshalBool unmarshals a bool from the buffer.
func UnmarshalByte ¶
UnmarshalByte unmarshals a byte from the buffer.
func UnmarshalBytes ¶
UnmarshalBytes unmarshals a byte slice from the buffer.
func UnmarshalFloat32 ¶
UnmarshalFloat32 unmarshals a float32 from the buffer.
func UnmarshalFloat64 ¶
UnmarshalFloat64 unmarshals a float64 from the buffer.
func UnmarshalInt ¶
UnmarshalInt unmarshals a signed integer from the buffer.
func UnmarshalInt16 ¶
UnmarshalInt16 unmarshals an int16 from the buffer.
func UnmarshalInt32 ¶
UnmarshalInt32 unmarshals an int32 from the buffer.
func UnmarshalInt64 ¶
UnmarshalInt64 unmarshals an int64 from the buffer.
func UnmarshalMap ¶
func UnmarshalMap[K comparable, V any](n int, b []byte, kUnmarshaler interface{}, vUnmarshaler interface{}) (int, map[K]V, error)
UnmarshalMap unmarshals a map from the buffer.
func UnmarshalSlice ¶
UnmarshalSlice unmarshals a slice from the buffer.
func UnmarshalString ¶
UnmarshalString unmarshals a string from the buffer.
func UnmarshalUint ¶
UnmarshalUint unmarshals an unsigned integer from the buffer.
func UnmarshalUint16 ¶
UnmarshalUint16 unmarshals a uint16 from the buffer.
func UnmarshalUint32 ¶
UnmarshalUint32 unmarshals a uint32 from the buffer.
Types ¶
type MarshalFunc ¶
MarshalFunc is a function that marshals a value of type T into a byte slice.
type Signed ¶
Signed is a constraint that permits any signed integer type. If future releases of Go add new predeclared signed integer types, this constraint will be modified to include them.
type StringHeader ¶
StringHeader is a string header.