Documentation ¶
Overview ¶
Package ztype provides (de)serialization functions for zserio primitive types.
Zserio defines a set of primitive types such as integer in various sizes, strings, floats and arrays. This package provides functions to read and write those types.
Normally you will never need to use this package directly. It is used by code that generated from zserio schemas.
Index ¶
- Constants
- Variables
- func BitSizeOfString(v string) (int, error)
- func CountAlignBits(bitPosition int, boundary uint8) int
- func CreatePackingContextNode[T any]() *zserio.PackingContextNode
- func NumBits(v uint64) int
- func ReadBool(r zserio.Reader) (bool, error)
- func ReadFloat16(r zserio.Reader) (float32, error)
- func ReadFloat32(r zserio.Reader) (float32, error)
- func ReadFloat64(r zserio.Reader) (float64, error)
- func ReadInt16(r zserio.Reader) (int16, error)
- func ReadInt32(r zserio.Reader) (int32, error)
- func ReadInt64(r zserio.Reader) (int64, error)
- func ReadInt8(r zserio.Reader) (int8, error)
- func ReadSignedBits(r zserio.Reader, bits uint8) (int64, error)
- func ReadString(r zserio.Reader) (string, error)
- func ReadUint16(r zserio.Reader) (uint16, error)
- func ReadUint32(r zserio.Reader) (uint32, error)
- func ReadUint64(r zserio.Reader) (uint64, error)
- func ReadUint8(r zserio.Reader) (uint8, error)
- func ReadUnsignedBits(r zserio.Reader, bits uint8) (uint64, error)
- func ReadVarint(r zserio.Reader) (int64, error)
- func ReadVarint16(r zserio.Reader) (int16, error)
- func ReadVarint32(r zserio.Reader) (int32, error)
- func ReadVarint64(r zserio.Reader) (int64, error)
- func ReadVarsize(r zserio.Reader) (uint64, error)
- func ReadVaruint(r zserio.Reader) (uint64, error)
- func ReadVaruint16(r zserio.Reader) (uint16, error)
- func ReadVaruint32(r zserio.Reader) (uint32, error)
- func ReadVaruint64(r zserio.Reader) (uint64, error)
- func SignedBitSize(v int64, maxBytes int) (int, error)
- func UnsignedBitSize(v uint64, maxBytes int) (int, error)
- func WriteBool(w zserio.Writer, v bool) error
- func WriteBytes(w zserio.Writer, b *BytesType) error
- func WriteExtern(w zserio.Writer, e *ExternType) error
- func WriteFloat16(w zserio.Writer, v float32) error
- func WriteFloat32(w zserio.Writer, v float32) error
- func WriteFloat64(w zserio.Writer, v float64) error
- func WriteInt16(w zserio.Writer, value int16) error
- func WriteInt32(w zserio.Writer, value int32) error
- func WriteInt64(w zserio.Writer, value int64) error
- func WriteInt8(w zserio.Writer, value int8) error
- func WriteSignedBits(w zserio.Writer, value int64, bits uint8) error
- func WriteString(w zserio.Writer, v string) error
- func WriteUint16(w zserio.Writer, value uint16) error
- func WriteUint32(w zserio.Writer, value uint32) error
- func WriteUint64(w zserio.Writer, value uint64) error
- func WriteUint8(w zserio.Writer, value uint8) error
- func WriteUnsignedBits(w zserio.Writer, value uint64, bits uint8) error
- func WriteVarint(w zserio.Writer, v int64) error
- func WriteVarint16(w zserio.Writer, v int16) error
- func WriteVarint32(w zserio.Writer, v int32) error
- func WriteVarint64(w zserio.Writer, v int64) error
- func WriteVarsize(w zserio.Writer, v uint64) error
- func WriteVaruint(w zserio.Writer, v uint64) error
- func WriteVaruint16(w zserio.Writer, v uint16) error
- func WriteVaruint32(w zserio.Writer, v uint32) error
- func WriteVaruint64(w zserio.Writer, v uint64) error
- type Array
- func (array *Array[T, Y]) Clone() zserio.ZserioType
- func (array *Array[T, Y]) MarshalZserio(writer zserio.Writer) error
- func (array *Array[T, Y]) Size() int
- func (array *Array[T, Y]) UnmarshalZserio(reader zserio.Reader) error
- func (array *Array[T, Y]) ZserioBitSize(bitPosition int) (int, error)
- func (array *Array[T, Y]) ZserioBitSizePacked(bitPosition int) (int, error)
- type ArrayOption
- type BitBufferArrayTraits
- func (trait BitBufferArrayTraits) AsUint64(value *ExternType) uint64
- func (trait BitBufferArrayTraits) BitSizeOf(element *ExternType, endBitPosition int) int
- func (trait BitBufferArrayTraits) BitSizeOfIsConstant() bool
- func (trait BitBufferArrayTraits) FromUint64(value uint64) *ExternType
- func (trait BitBufferArrayTraits) InitializeOffsets(bitPosition int, value *ExternType) int
- func (trait BitBufferArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait BitBufferArrayTraits) NeedsReadIndex() bool
- func (trait BitBufferArrayTraits) PackedTraits() IPackedArrayTraits[*ExternType]
- func (trait BitBufferArrayTraits) Read(reader zserio.Reader, endBitPosition int) (*ExternType, error)
- func (trait BitBufferArrayTraits) Write(writer zserio.Writer, value *ExternType) error
- type BitFieldArrayTraits
- func (trait BitFieldArrayTraits[T]) AsUint64(value T) uint64
- func (trait BitFieldArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
- func (trait BitFieldArrayTraits[T]) BitSizeOfIsConstant() bool
- func (trait BitFieldArrayTraits[T]) FromUint64(value uint64) T
- func (trait BitFieldArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
- func (trait BitFieldArrayTraits[T]) NeedsBitsizeOfPosition() bool
- func (trait BitFieldArrayTraits[T]) NeedsReadIndex() bool
- func (trait BitFieldArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
- func (trait BitFieldArrayTraits[T]) Read(reader zserio.Reader, index int) (T, error)
- func (trait BitFieldArrayTraits[T]) Write(writer zserio.Writer, value T) error
- type BooleanArrayTraits
- func (trait BooleanArrayTraits) AsUint64(value bool) uint64
- func (trait BooleanArrayTraits) BitSizeOf(element bool, endBitPosition int) int
- func (trait BooleanArrayTraits) BitSizeOfIsConstant() bool
- func (trait BooleanArrayTraits) FromUint64(value uint64) bool
- func (trait BooleanArrayTraits) InitializeOffsets(bitPosition int, value bool) int
- func (trait BooleanArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait BooleanArrayTraits) NeedsReadIndex() bool
- func (trait BooleanArrayTraits) PackedTraits() IPackedArrayTraits[bool]
- func (trait BooleanArrayTraits) Read(reader zserio.Reader, index int) (bool, error)
- func (trait BooleanArrayTraits) Write(writer zserio.Writer, value bool) error
- type BytesArrayTraits
- func (trait BytesArrayTraits) AsUint64(value *BytesType) uint64
- func (trait BytesArrayTraits) BitSizeOf(element *BytesType, endBitPosition int) int
- func (trait BytesArrayTraits) BitSizeOfIsConstant() bool
- func (trait BytesArrayTraits) FromUint64(value uint64) *BytesType
- func (trait BytesArrayTraits) InitializeOffsets(bitPosition int, value *BytesType) int
- func (trait BytesArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait BytesArrayTraits) NeedsReadIndex() bool
- func (trait BytesArrayTraits) PackedTraits() IPackedArrayTraits[*BytesType]
- func (trait BytesArrayTraits) Read(reader zserio.Reader, endBitPosition int) (*BytesType, error)
- func (trait BytesArrayTraits) Write(writer zserio.Writer, value *BytesType) error
- type BytesType
- type DeltaContext
- func (context *DeltaContext[T]) BitSizeOf(arrayTraits IArrayTraits[T], bitPosition int, element T) (int, error)
- func (context *DeltaContext[T]) BitSizeOfDescriptor() int
- func (context *DeltaContext[T]) Init(arrayTraits IArrayTraits[T], element T)
- func (context *DeltaContext[T]) Read(arrayTraits IArrayTraits[T], reader zserio.Reader) (T, error)
- func (context *DeltaContext[T]) ReadDescriptor(reader zserio.Reader) error
- func (context *DeltaContext[T]) Write(arrayTraits IArrayTraits[T], writer zserio.Writer, element T) error
- func (context *DeltaContext[T]) WriteDescriptor(writer zserio.Writer) error
- type ExternType
- type Float16ArrayTraits
- func (trait Float16ArrayTraits) AsUint64(value float32) uint64
- func (trait Float16ArrayTraits) BitSizeOf(element float32, endBitPosition int) int
- func (trait Float16ArrayTraits) BitSizeOfIsConstant() bool
- func (trait Float16ArrayTraits) FromUint64(value uint64) float32
- func (trait Float16ArrayTraits) InitializeOffsets(bitPosition int, value float32) int
- func (trait Float16ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait Float16ArrayTraits) NeedsReadIndex() bool
- func (trait Float16ArrayTraits) PackedTraits() IPackedArrayTraits[float32]
- func (trait Float16ArrayTraits) Read(reader zserio.Reader, index int) (float32, error)
- func (trait Float16ArrayTraits) Write(writer zserio.Writer, value float32) error
- type Float32ArrayTraits
- func (trait Float32ArrayTraits) AsUint64(value float32) uint64
- func (trait Float32ArrayTraits) BitSizeOf(element float32, endBitPosition int) int
- func (trait Float32ArrayTraits) BitSizeOfIsConstant() bool
- func (trait Float32ArrayTraits) FromUint64(value uint64) float32
- func (trait Float32ArrayTraits) InitializeOffsets(bitPosition int, value float32) int
- func (trait Float32ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait Float32ArrayTraits) NeedsReadIndex() bool
- func (trait Float32ArrayTraits) PackedTraits() IPackedArrayTraits[float32]
- func (trait Float32ArrayTraits) Read(reader zserio.Reader, index int) (float32, error)
- func (trait Float32ArrayTraits) Write(writer zserio.Writer, value float32) error
- type Float64ArrayTraits
- func (trait Float64ArrayTraits) AsUint64(value float64) uint64
- func (trait Float64ArrayTraits) BitSizeOf(element float64, endBitPosition int) int
- func (trait Float64ArrayTraits) BitSizeOfIsConstant() bool
- func (trait Float64ArrayTraits) FromUint64(value uint64) float64
- func (trait Float64ArrayTraits) InitializeOffsets(bitPosition int, value float64) int
- func (trait Float64ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait Float64ArrayTraits) NeedsReadIndex() bool
- func (trait Float64ArrayTraits) PackedTraits() IPackedArrayTraits[float64]
- func (trait Float64ArrayTraits) Read(reader zserio.Reader, index int) (float64, error)
- func (trait Float64ArrayTraits) Write(writer zserio.Writer, value float64) error
- type IArrayTraits
- type IPackedArrayTraits
- type ObjectArrayTraits
- func (trait ObjectArrayTraits[T]) AsUint64(value T) uint64
- func (trait ObjectArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
- func (trait ObjectArrayTraits[T]) BitSizeOfIsConstant() bool
- func (trait ObjectArrayTraits[T]) FromUint64(value uint64) T
- func (trait ObjectArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
- func (trait ObjectArrayTraits[T]) NeedsBitsizeOfPosition() bool
- func (trait ObjectArrayTraits[T]) NeedsReadIndex() bool
- func (trait ObjectArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
- func (trait ObjectArrayTraits[T]) Read(reader zserio.Reader, index int) (T, error)
- func (trait ObjectArrayTraits[T]) Write(writer zserio.Writer, value T) error
- type ObjectCreator
- type ObjectPackedArrayTraits
- func (traits *ObjectPackedArrayTraits[T, Y]) BitSizeOf(contextNode *zserio.PackingContextNode, bitPosition int, element T) (int, error)
- func (traits *ObjectPackedArrayTraits[T, Y]) CreateContext() (*zserio.PackingContextNode, error)
- func (traits *ObjectPackedArrayTraits[T, Y]) InitContext(contextNode *zserio.PackingContextNode, element T) error
- func (traits *ObjectPackedArrayTraits[T, Y]) InitializeOffsets(contextNode *zserio.PackingContextNode, bitPosition int, element T) int
- func (traits *ObjectPackedArrayTraits[T, Y]) Read(contextNode *zserio.PackingContextNode, reader zserio.Reader, index int) (T, error)
- func (traits *ObjectPackedArrayTraits[T, Y]) Write(contextNode *zserio.PackingContextNode, writer zserio.Writer, element T)
- type OffsetMethod
- type PackedArrayTraits
- func (traits *PackedArrayTraits[T, Y]) BitSizeOf(contextNode *zserio.PackingContextNode, bitPosition int, element T) (int, error)
- func (traits *PackedArrayTraits[T, Y]) CreateContext() (*zserio.PackingContextNode, error)
- func (traits *PackedArrayTraits[T, Y]) InitContext(contextNode *zserio.PackingContextNode, element T) error
- func (traits *PackedArrayTraits[T, Y]) InitializeOffsets(contextNode *zserio.PackingContextNode, bitPosition int, element T) int
- func (traits *PackedArrayTraits[T, Y]) Read(contextNode *zserio.PackingContextNode, reader zserio.Reader, index int) (T, error)
- func (traits *PackedArrayTraits[T, Y]) Write(contextNode *zserio.PackingContextNode, writer zserio.Writer, value T)
- type SignedBitFieldArrayTraits
- func (trait SignedBitFieldArrayTraits[T]) AsUint64(value T) uint64
- func (trait SignedBitFieldArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
- func (trait SignedBitFieldArrayTraits[T]) BitSizeOfIsConstant() bool
- func (trait SignedBitFieldArrayTraits[T]) FromUint64(value uint64) T
- func (trait SignedBitFieldArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
- func (trait SignedBitFieldArrayTraits[T]) NeedsBitsizeOfPosition() bool
- func (trait SignedBitFieldArrayTraits[T]) NeedsReadIndex() bool
- func (trait SignedBitFieldArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
- func (trait SignedBitFieldArrayTraits[T]) Read(reader zserio.Reader, index int) (T, error)
- func (trait SignedBitFieldArrayTraits[T]) Write(writer zserio.Writer, value T) error
- type StringArrayTraits
- func (trait StringArrayTraits) AsUint64(value string) uint64
- func (trait StringArrayTraits) BitSizeOf(element string, endBitPosition int) int
- func (trait StringArrayTraits) BitSizeOfIsConstant() bool
- func (trait StringArrayTraits) FromUint64(value uint64) string
- func (trait StringArrayTraits) InitializeOffsets(bitPosition int, value string) int
- func (trait StringArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait StringArrayTraits) NeedsReadIndex() bool
- func (trait StringArrayTraits) PackedTraits() IPackedArrayTraits[string]
- func (trait StringArrayTraits) Read(reader zserio.Reader, index int) (string, error)
- func (trait StringArrayTraits) Write(writer zserio.Writer, value string) error
- type VarInt16ArrayTraits
- func (trait VarInt16ArrayTraits) AsUint64(value int16) uint64
- func (trait VarInt16ArrayTraits) BitSizeOf(element int16, endBitPosition int) int
- func (trait VarInt16ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarInt16ArrayTraits) FromUint64(value uint64) int16
- func (trait VarInt16ArrayTraits) InitializeOffsets(bitPosition int, value int16) int
- func (trait VarInt16ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarInt16ArrayTraits) NeedsReadIndex() bool
- func (trait VarInt16ArrayTraits) PackedTraits() IPackedArrayTraits[int16]
- func (trait VarInt16ArrayTraits) Read(reader zserio.Reader, index int) (int16, error)
- func (trait VarInt16ArrayTraits) Write(writer zserio.Writer, value int16) error
- type VarInt32ArrayTraits
- func (trait VarInt32ArrayTraits) AsUint64(value int32) uint64
- func (trait VarInt32ArrayTraits) BitSizeOf(element int32, endBitPosition int) int
- func (trait VarInt32ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarInt32ArrayTraits) FromUint64(value uint64) int32
- func (trait VarInt32ArrayTraits) InitializeOffsets(bitPosition int, value int32) int
- func (trait VarInt32ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarInt32ArrayTraits) NeedsReadIndex() bool
- func (trait VarInt32ArrayTraits) PackedTraits() IPackedArrayTraits[int32]
- func (trait VarInt32ArrayTraits) Read(reader zserio.Reader, index int) (int32, error)
- func (trait VarInt32ArrayTraits) Write(writer zserio.Writer, value int32) error
- type VarInt64ArrayTraits
- func (trait VarInt64ArrayTraits) AsUint64(value int64) uint64
- func (trait VarInt64ArrayTraits) BitSizeOf(element int64, endBitPosition int) int
- func (trait VarInt64ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarInt64ArrayTraits) FromUint64(value uint64) int64
- func (trait VarInt64ArrayTraits) InitializeOffsets(bitPosition int, value int64) int
- func (trait VarInt64ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarInt64ArrayTraits) NeedsReadIndex() bool
- func (trait VarInt64ArrayTraits) PackedTraits() IPackedArrayTraits[int64]
- func (trait VarInt64ArrayTraits) Read(reader zserio.Reader, index int) (int64, error)
- func (trait VarInt64ArrayTraits) Write(writer zserio.Writer, value int64) error
- type VarIntArrayTraits
- func (trait VarIntArrayTraits) AsUint64(value int64) uint64
- func (trait VarIntArrayTraits) BitSizeOf(element int64, endBitPosition int) int
- func (trait VarIntArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarIntArrayTraits) FromUint64(value uint64) int64
- func (trait VarIntArrayTraits) InitializeOffsets(bitPosition int, value int64) int
- func (trait VarIntArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarIntArrayTraits) NeedsReadIndex() bool
- func (trait VarIntArrayTraits) PackedTraits() IPackedArrayTraits[int64]
- func (trait VarIntArrayTraits) Read(reader zserio.Reader, index int) (int64, error)
- func (trait VarIntArrayTraits) Write(writer zserio.Writer, value int64) error
- type VarSizeArrayTraits
- func (trait VarSizeArrayTraits) AsUint64(value uint64) uint64
- func (trait VarSizeArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
- func (trait VarSizeArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarSizeArrayTraits) FromUint64(value uint64) uint64
- func (trait VarSizeArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
- func (trait VarSizeArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarSizeArrayTraits) NeedsReadIndex() bool
- func (trait VarSizeArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
- func (trait VarSizeArrayTraits) Read(reader zserio.Reader, index int) (uint64, error)
- func (trait VarSizeArrayTraits) Write(writer zserio.Writer, value uint64) error
- type VarUInt16ArrayTraits
- func (trait VarUInt16ArrayTraits) AsUint64(value uint16) uint64
- func (trait VarUInt16ArrayTraits) BitSizeOf(element uint16, endBitPosition int) int
- func (trait VarUInt16ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarUInt16ArrayTraits) FromUint64(value uint64) uint16
- func (trait VarUInt16ArrayTraits) InitializeOffsets(bitPosition int, value uint16) int
- func (trait VarUInt16ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarUInt16ArrayTraits) NeedsReadIndex() bool
- func (trait VarUInt16ArrayTraits) PackedTraits() IPackedArrayTraits[uint16]
- func (trait VarUInt16ArrayTraits) Read(reader zserio.Reader, index int) (uint16, error)
- func (trait VarUInt16ArrayTraits) Write(writer zserio.Writer, value uint16) error
- type VarUInt32ArrayTraits
- func (trait VarUInt32ArrayTraits) AsUint64(value uint32) uint64
- func (trait VarUInt32ArrayTraits) BitSizeOf(element uint32, endBitPosition int) int
- func (trait VarUInt32ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarUInt32ArrayTraits) FromUint64(value uint64) uint32
- func (trait VarUInt32ArrayTraits) InitializeOffsets(bitPosition int, value uint32) int
- func (trait VarUInt32ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarUInt32ArrayTraits) NeedsReadIndex() bool
- func (trait VarUInt32ArrayTraits) PackedTraits() IPackedArrayTraits[uint32]
- func (trait VarUInt32ArrayTraits) Read(reader zserio.Reader, index int) (uint32, error)
- func (trait VarUInt32ArrayTraits) Write(writer zserio.Writer, value uint32) error
- type VarUInt64ArrayTraits
- func (trait VarUInt64ArrayTraits) AsUint64(value uint64) uint64
- func (trait VarUInt64ArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
- func (trait VarUInt64ArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarUInt64ArrayTraits) FromUint64(value uint64) uint64
- func (trait VarUInt64ArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
- func (trait VarUInt64ArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarUInt64ArrayTraits) NeedsReadIndex() bool
- func (trait VarUInt64ArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
- func (trait VarUInt64ArrayTraits) Read(reader zserio.Reader, index int) (uint64, error)
- func (trait VarUInt64ArrayTraits) Write(writer zserio.Writer, value uint64) error
- type VarUIntArrayTraits
- func (trait VarUIntArrayTraits) AsUint64(value uint64) uint64
- func (trait VarUIntArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
- func (trait VarUIntArrayTraits) BitSizeOfIsConstant() bool
- func (trait VarUIntArrayTraits) FromUint64(value uint64) uint64
- func (trait VarUIntArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
- func (trait VarUIntArrayTraits) NeedsBitsizeOfPosition() bool
- func (trait VarUIntArrayTraits) NeedsReadIndex() bool
- func (trait VarUIntArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
- func (trait VarUIntArrayTraits) Read(reader zserio.Reader, index int) (uint64, error)
- func (trait VarUIntArrayTraits) Write(writer zserio.Writer, value uint64) error
Constants ¶
const ( MaxInt8 = (1 << 7) - 1 MinInt8 = -1 << 7 MaxInt16 = (1 << 15) - 1 MinInt16 = -1 << 15 MaxInt32 = (1 << 31) - 1 MinInt32 = -1 << 31 MaxInt64 = (1 << 63) - 1 MinInt64 = -1 << 63 MaxUint8 = (1 << 8) - 1 MinUint8 = 0 MaxUint16 = (1 << 16) - 1 MinUint16 = 0 MaxUint32 = (1 << 32) - 1 MinUint32 = 0 MaxUint64 = (1 << 64) - 1 MinUint64 = 0 MaxVarint16 = (1 << (6 + 8)) - 1 MinVarint16 = -MaxVarint16 MaxVarint32 = (1 << (6 + 7 + 7 + 8)) - 1 MinVarint32 = -MaxVarint32 MaxVarint64 = (1 << (6 + 7 + 7 + 7 + 7 + 7 + 7 + 8)) - 1 MinVarint64 = -MaxVarint64 MaxVarint = MaxInt64 MinVarint = MinInt64 MaxVaruint16 = (1 << (7 + 8)) - 1 MinVaruint16 = 0 MaxVaruint32 = (1 << (7 + 7 + 7 + 8)) - 1 MinVaruint32 = 0 MaxVaruint64 = (1 << (7 + 7 + 7 + 7 + 7 + 7 + 7 + 8)) - 1 MinVaruint64 = 0 MaxVaruint = MaxUint64 MinVaruint = 0 MaxVarsize = (1 << (2 + 7 + 7 + 7 + 8)) - 1 MinVarsize = 0 )
These constants define the minimum and maximum allowed values of the zserio numeric types.
Variables ¶
var ErrOutOfBounds = errors.New("value too large or too small for type")
ErrOutOfBounds is an error that is returned when you try to write a value that is too large for the zserio (integer) type.
var ErrValueOutOfBitRange = errors.New("value is out of range for the given number of bits")
ErrValueOutOfBitRange is returned when you try to write a bit field type with a value that is larger than the number of bits allows for.
Functions ¶
func BitSizeOfString ¶
BitSizeOfString returns the zserio bit size of a string.
func CountAlignBits ¶
CountAlignBits calculates how many bits would need to be spend to align the current bitPosition to the next boundary.
func CreatePackingContextNode ¶
func CreatePackingContextNode[T any]() *zserio.PackingContextNode
CreatePackingContextNode creates a new PackingContextNode using a delta context.
func NumBits ¶ added in v0.2.3
NumBits returns the exact number of bits needed to represent an unsigned integer in zserio, considering the fact that 0 is not counted, due to the zserio encoding.
func ReadFloat16 ¶
ReadFloat16 reads a 16-bit floating point number.
func ReadFloat32 ¶
ReadFloat32 reads a 32-bit floating point number.
func ReadFloat64 ¶
ReadFloat64 reads a 64-bit floating point number.
func ReadSignedBits ¶
ReadSignedBits reads an signed number with a given number of bits
func ReadString ¶
ReadString reads a string from the bitstream.
func ReadUint16 ¶
ReadUint16 reads an unsigned 16-bit integer.
func ReadUint32 ¶
ReadUint32 reads an unsigned 32-bit integer.
func ReadUint64 ¶
ReadUint64 reads an unsigned 64-bit integer.
func ReadUnsignedBits ¶
ReadUnsignedBits reads an unsigned number with a given number of bits
func ReadVarint ¶
ReadVarint reads a zserio varint value from the bitstream.
func ReadVarint16 ¶
ReadVarint16 reads a zserio varint16 value from the bitstream.
func ReadVarint32 ¶
ReadVarint32 reads a zserio varint32 value from the bitstream.
func ReadVarint64 ¶
ReadVarint64 reads a zserio varint64 value from the bitstream.
func ReadVarsize ¶
ReadVarsize reads a zserio varsize value from the bitstream
func ReadVaruint ¶
ReadVaruint reads a zserio varuint value from the bitstream
func ReadVaruint16 ¶
ReadVaruint16 reads a zserio varuint16 value from the bitstream
func ReadVaruint32 ¶
ReadVaruint32 reads a zserio varuint32 value from the bitstream
func ReadVaruint64 ¶
ReadVaruint64 reads a zserio varuint64 value from the bitstream
func SignedBitSize ¶
SignedBitSize returns the size in bits of the zserio encoding of a signed value.
func UnsignedBitSize ¶
UnsignedBitSize returns the size in bits of the zserio encoding of an unsigned value.
func WriteBytes ¶ added in v0.7.0
WriteBytes writes an zserio bytes type (variable size byte buffer) from a reader.
func WriteExtern ¶
func WriteExtern(w zserio.Writer, e *ExternType) error
WriteExtern writes an zserio extern type (variable size bitbuffer) from a reader.
func WriteFloat16 ¶
WriteFloat16 writes a float value in half precision (FP16) format.
func WriteFloat32 ¶
WriteFloat32 writes a float32 to the bitstream.
func WriteFloat64 ¶
WriteFloat64 writes a float64 to the bitstream.
func WriteInt16 ¶
WriteInt16 writes a signed 16-bit integer.
func WriteInt32 ¶
WriteInt32 writes a signed 32-bit integer.
func WriteInt64 ¶
WriteInt64 writes a signed 64-bit integer.
func WriteSignedBits ¶
WriteSignedBits writes an signed number with a given number of bits
func WriteString ¶
WriteString writes a string value to the bitstream.
func WriteUint16 ¶
WriteUint16 writes an unsigned 16-bit integer.
func WriteUint32 ¶
WriteUint32 writes an unsigned 32-bit integer.
func WriteUint64 ¶
WriteUint64 writes an unsigned 64-bit integer.
func WriteUint8 ¶
WriteUint8 writes an unsigned 8-bit integer.
func WriteUnsignedBits ¶
WriteUnsignedBits writes an unsigned number with a given number of bits
func WriteVarint ¶
WriteVarint writes a zserio varint value to the bitstream. If you pass in a value that is outside to allowed range of (MinVarint, MaxVarint) ErrOutOfBounds will be returned.
func WriteVarint16 ¶
WriteVarint16 writes a zserio varint16 value to the bitstream. If you pass in a value that is outside to allowed range of (MinVarint16, MaxVarint16) ErrOutOfBounds will be returned.
func WriteVarint32 ¶
WriteVarint32 writes a zserio varint32 value to the bitstream. If you pass in a value that is outside to allowed range of (MinVarint32, MaxVarint32) ErrOutOfBounds will be returned.
func WriteVarint64 ¶
WriteVarint64 writes a zserio varint64 value to the bitstream. If you pass in a value that is outside to allowed range of (MinVarint64, MaxVarint64) ErrOutOfBounds will be returned.
func WriteVarsize ¶
WriteVarsize writes a zserio varsize value to the bitstream. If you pass in a value that is outside to allowed range of (MinVarsize, MaxVarsize) ErrOutOfBounds will be returned.
func WriteVaruint ¶
WriteVaruint writes a zserio varuint value to the bitstream. If you pass in a value that is outside to allowed range of (MinVaruint, MaxVaruint) ErrOutOfBounds will be returned.
func WriteVaruint16 ¶
WriteVaruint16 writes a zserio varuint16 value to the bitstream. If you pass in a value that is outside to allowed range of (MinVaruint16, MaxVaruint16) ErrOutOfBounds will be returned.
func WriteVaruint32 ¶
WriteVaruint32 writes a zserio varuint32 value to the bitstream. If you pass in a value that is outside to allowed range of (MinVaruint32, MaxVaruint32) ErrOutOfBounds will be returned.
Types ¶
type Array ¶
type Array[T any, Y IArrayTraits[T]] struct { // ArrayTraits are the array traits used. ArrayTraits Y // RawArray is a reference to the raw array. RawArray []T // IsAuto specifies if the array size is automatically calculated. IsAuto bool // IsPacked specifies if the array is packed. IsPacked bool // FixedSize is the size of the array, if the array is of fixed size FixedSize int // The node used by this array for packing PackedContext *zserio.PackingContextNode // contains filtered or unexported fields }
Array allows representing arrays of any type and serialize them to the zserio format.
func ArrayFromReader ¶
func ArrayFromReader[T any, Y IArrayTraits[T]](reader zserio.Reader, arrayTraits Y, size int, isPacked, isAuto bool, options ...ArrayOption[T, Y]) (*Array[T, Y], error)
ArrayFromReader is a helper function to read an array as a one-liner.
func (*Array[T, Y]) Clone ¶
func (array *Array[T, Y]) Clone() zserio.ZserioType
Clone does a deep copy of the array.
func (*Array[T, Y]) MarshalZserio ¶
MarshalZserio writes an array to a bit writer.
func (*Array[T, Y]) UnmarshalZserio ¶
UnmarshalZserio reads an array from a bit reader, in either packed or unpacked configuration.
func (*Array[T, Y]) ZserioBitSize ¶
ZserioBitSize returns the total size of the unpacked array in bits.
type ArrayOption ¶
type ArrayOption[T any, Y IArrayTraits[T]] interface { // contains filtered or unexported methods }
ArrayOption allows to customize array creation.
func WithCheckOffsetMethod ¶
func WithCheckOffsetMethod[T any, Y IArrayTraits[T]](fn OffsetMethod) ArrayOption[T, Y]
func WithSetOffsetMethod ¶
func WithSetOffsetMethod[T any, Y IArrayTraits[T]](fn OffsetMethod) ArrayOption[T, Y]
type BitBufferArrayTraits ¶ added in v0.7.0
type BitBufferArrayTraits struct{}
func (BitBufferArrayTraits) AsUint64 ¶ added in v0.7.0
func (trait BitBufferArrayTraits) AsUint64(value *ExternType) uint64
func (BitBufferArrayTraits) BitSizeOf ¶ added in v0.7.0
func (trait BitBufferArrayTraits) BitSizeOf(element *ExternType, endBitPosition int) int
func (BitBufferArrayTraits) BitSizeOfIsConstant ¶ added in v0.7.0
func (trait BitBufferArrayTraits) BitSizeOfIsConstant() bool
func (BitBufferArrayTraits) FromUint64 ¶ added in v0.7.0
func (trait BitBufferArrayTraits) FromUint64(value uint64) *ExternType
func (BitBufferArrayTraits) InitializeOffsets ¶ added in v0.7.0
func (trait BitBufferArrayTraits) InitializeOffsets(bitPosition int, value *ExternType) int
func (BitBufferArrayTraits) NeedsBitsizeOfPosition ¶ added in v0.7.0
func (trait BitBufferArrayTraits) NeedsBitsizeOfPosition() bool
func (BitBufferArrayTraits) NeedsReadIndex ¶ added in v0.7.0
func (trait BitBufferArrayTraits) NeedsReadIndex() bool
func (BitBufferArrayTraits) PackedTraits ¶ added in v0.7.0
func (trait BitBufferArrayTraits) PackedTraits() IPackedArrayTraits[*ExternType]
func (BitBufferArrayTraits) Read ¶ added in v0.7.0
func (trait BitBufferArrayTraits) Read(reader zserio.Reader, endBitPosition int) (*ExternType, error)
func (BitBufferArrayTraits) Write ¶ added in v0.7.0
func (trait BitBufferArrayTraits) Write(writer zserio.Writer, value *ExternType) error
type BitFieldArrayTraits ¶
type BitFieldArrayTraits[T constraints.Integer] struct { NumBits uint8 }
func (BitFieldArrayTraits[T]) AsUint64 ¶
func (trait BitFieldArrayTraits[T]) AsUint64(value T) uint64
func (BitFieldArrayTraits[T]) BitSizeOf ¶
func (trait BitFieldArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
func (BitFieldArrayTraits[T]) BitSizeOfIsConstant ¶
func (trait BitFieldArrayTraits[T]) BitSizeOfIsConstant() bool
func (BitFieldArrayTraits[T]) FromUint64 ¶
func (trait BitFieldArrayTraits[T]) FromUint64(value uint64) T
func (BitFieldArrayTraits[T]) InitializeOffsets ¶
func (trait BitFieldArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
func (BitFieldArrayTraits[T]) NeedsBitsizeOfPosition ¶
func (trait BitFieldArrayTraits[T]) NeedsBitsizeOfPosition() bool
func (BitFieldArrayTraits[T]) NeedsReadIndex ¶
func (trait BitFieldArrayTraits[T]) NeedsReadIndex() bool
func (BitFieldArrayTraits[T]) PackedTraits ¶
func (trait BitFieldArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
type BooleanArrayTraits ¶ added in v0.5.1
type BooleanArrayTraits struct{}
func (BooleanArrayTraits) AsUint64 ¶ added in v0.5.1
func (trait BooleanArrayTraits) AsUint64(value bool) uint64
func (BooleanArrayTraits) BitSizeOf ¶ added in v0.5.1
func (trait BooleanArrayTraits) BitSizeOf(element bool, endBitPosition int) int
func (BooleanArrayTraits) BitSizeOfIsConstant ¶ added in v0.5.1
func (trait BooleanArrayTraits) BitSizeOfIsConstant() bool
func (BooleanArrayTraits) FromUint64 ¶ added in v0.5.1
func (trait BooleanArrayTraits) FromUint64(value uint64) bool
func (BooleanArrayTraits) InitializeOffsets ¶ added in v0.5.1
func (trait BooleanArrayTraits) InitializeOffsets(bitPosition int, value bool) int
func (BooleanArrayTraits) NeedsBitsizeOfPosition ¶ added in v0.5.1
func (trait BooleanArrayTraits) NeedsBitsizeOfPosition() bool
func (BooleanArrayTraits) NeedsReadIndex ¶ added in v0.5.1
func (trait BooleanArrayTraits) NeedsReadIndex() bool
func (BooleanArrayTraits) PackedTraits ¶ added in v0.5.1
func (trait BooleanArrayTraits) PackedTraits() IPackedArrayTraits[bool]
type BytesArrayTraits ¶ added in v0.7.0
type BytesArrayTraits struct{}
func (BytesArrayTraits) AsUint64 ¶ added in v0.7.0
func (trait BytesArrayTraits) AsUint64(value *BytesType) uint64
func (BytesArrayTraits) BitSizeOf ¶ added in v0.7.0
func (trait BytesArrayTraits) BitSizeOf(element *BytesType, endBitPosition int) int
func (BytesArrayTraits) BitSizeOfIsConstant ¶ added in v0.7.0
func (trait BytesArrayTraits) BitSizeOfIsConstant() bool
func (BytesArrayTraits) FromUint64 ¶ added in v0.7.0
func (trait BytesArrayTraits) FromUint64(value uint64) *BytesType
func (BytesArrayTraits) InitializeOffsets ¶ added in v0.7.0
func (trait BytesArrayTraits) InitializeOffsets(bitPosition int, value *BytesType) int
func (BytesArrayTraits) NeedsBitsizeOfPosition ¶ added in v0.7.0
func (trait BytesArrayTraits) NeedsBitsizeOfPosition() bool
func (BytesArrayTraits) NeedsReadIndex ¶ added in v0.7.0
func (trait BytesArrayTraits) NeedsReadIndex() bool
func (BytesArrayTraits) PackedTraits ¶ added in v0.7.0
func (trait BytesArrayTraits) PackedTraits() IPackedArrayTraits[*BytesType]
type BytesType ¶ added in v0.7.0
type BytesType struct { // BitSize is the size of the buffer in bytes ByteSize uint64 // Buffer is the content of the zserio byte type Buffer []byte }
BytesType is a helper struct to store byte blobs in zserio
type DeltaContext ¶
type DeltaContext[T any] struct { // contains filtered or unexported fields }
DeltaContext is a packing context used when writing data using delta packing, i.e. instead of storing all values, only stores the deltas.
func (*DeltaContext[T]) BitSizeOf ¶
func (context *DeltaContext[T]) BitSizeOf(arrayTraits IArrayTraits[T], bitPosition int, element T) (int, error)
BitSizeOf returns the size of the delta context array in bits.
func (*DeltaContext[T]) BitSizeOfDescriptor ¶
func (context *DeltaContext[T]) BitSizeOfDescriptor() int
BitSizeOfDescriptor returns the bit size of a delta context array descriptor.
func (*DeltaContext[T]) Init ¶
func (context *DeltaContext[T]) Init(arrayTraits IArrayTraits[T], element T)
Init initializes a delta context array, and calculates the needed space per element in the final array.
func (*DeltaContext[T]) Read ¶
func (context *DeltaContext[T]) Read(arrayTraits IArrayTraits[T], reader zserio.Reader) (T, error)
Read reads the next element of an array encoded using delta contexts.
func (*DeltaContext[T]) ReadDescriptor ¶
func (context *DeltaContext[T]) ReadDescriptor(reader zserio.Reader) error
ReadDescriptor reads the descriptor of a delta packed context.
func (*DeltaContext[T]) Write ¶
func (context *DeltaContext[T]) Write(arrayTraits IArrayTraits[T], writer zserio.Writer, element T) error
Write writes an element of an delta context array.
func (*DeltaContext[T]) WriteDescriptor ¶
func (context *DeltaContext[T]) WriteDescriptor(writer zserio.Writer) error
WriteDescriptor writes the descriptor of a delta packed context.
type ExternType ¶
type ExternType struct { // BitSize is the size of the buffer in bits BitSize uint64 // Buffer is the content of the zserio extern type Buffer []byte }
ExternType is a helper struct to store zserio extern types
func ReadExtern ¶
func ReadExtern(r zserio.Reader) (*ExternType, error)
ReadExtern reads an zserio extern type (variable size bitbuffer) from a reader.
type Float16ArrayTraits ¶
type Float16ArrayTraits struct{}
Float16ArrayTraits is an array trait implementation for float16 arrays.
func (Float16ArrayTraits) AsUint64 ¶
func (trait Float16ArrayTraits) AsUint64(value float32) uint64
func (Float16ArrayTraits) BitSizeOf ¶
func (trait Float16ArrayTraits) BitSizeOf(element float32, endBitPosition int) int
func (Float16ArrayTraits) BitSizeOfIsConstant ¶
func (trait Float16ArrayTraits) BitSizeOfIsConstant() bool
func (Float16ArrayTraits) FromUint64 ¶
func (trait Float16ArrayTraits) FromUint64(value uint64) float32
func (Float16ArrayTraits) InitializeOffsets ¶
func (trait Float16ArrayTraits) InitializeOffsets(bitPosition int, value float32) int
func (Float16ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait Float16ArrayTraits) NeedsBitsizeOfPosition() bool
func (Float16ArrayTraits) NeedsReadIndex ¶
func (trait Float16ArrayTraits) NeedsReadIndex() bool
func (Float16ArrayTraits) PackedTraits ¶
func (trait Float16ArrayTraits) PackedTraits() IPackedArrayTraits[float32]
type Float32ArrayTraits ¶
type Float32ArrayTraits struct{}
Float32ArrayTraits is an array trait implementation for float32 arrays.
func (Float32ArrayTraits) AsUint64 ¶
func (trait Float32ArrayTraits) AsUint64(value float32) uint64
func (Float32ArrayTraits) BitSizeOf ¶
func (trait Float32ArrayTraits) BitSizeOf(element float32, endBitPosition int) int
func (Float32ArrayTraits) BitSizeOfIsConstant ¶
func (trait Float32ArrayTraits) BitSizeOfIsConstant() bool
func (Float32ArrayTraits) FromUint64 ¶
func (trait Float32ArrayTraits) FromUint64(value uint64) float32
func (Float32ArrayTraits) InitializeOffsets ¶
func (trait Float32ArrayTraits) InitializeOffsets(bitPosition int, value float32) int
func (Float32ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait Float32ArrayTraits) NeedsBitsizeOfPosition() bool
func (Float32ArrayTraits) NeedsReadIndex ¶
func (trait Float32ArrayTraits) NeedsReadIndex() bool
func (Float32ArrayTraits) PackedTraits ¶
func (trait Float32ArrayTraits) PackedTraits() IPackedArrayTraits[float32]
type Float64ArrayTraits ¶
type Float64ArrayTraits struct{}
Float64ArrayTraits is an array trait implementation for float64 arrays.
func (Float64ArrayTraits) AsUint64 ¶
func (trait Float64ArrayTraits) AsUint64(value float64) uint64
func (Float64ArrayTraits) BitSizeOf ¶
func (trait Float64ArrayTraits) BitSizeOf(element float64, endBitPosition int) int
func (Float64ArrayTraits) BitSizeOfIsConstant ¶
func (trait Float64ArrayTraits) BitSizeOfIsConstant() bool
func (Float64ArrayTraits) FromUint64 ¶
func (trait Float64ArrayTraits) FromUint64(value uint64) float64
func (Float64ArrayTraits) InitializeOffsets ¶
func (trait Float64ArrayTraits) InitializeOffsets(bitPosition int, value float64) int
func (Float64ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait Float64ArrayTraits) NeedsBitsizeOfPosition() bool
func (Float64ArrayTraits) NeedsReadIndex ¶
func (trait Float64ArrayTraits) NeedsReadIndex() bool
func (Float64ArrayTraits) PackedTraits ¶
func (trait Float64ArrayTraits) PackedTraits() IPackedArrayTraits[float64]
type IArrayTraits ¶
type IArrayTraits[T any] interface { // BitSizeOfIsConstant returns true if the bit size is constant for every // array element, for example int32. BitSizeOfIsConstant() bool // NeedsBitsizeOfPosition is true if the array traits need to know the bit // size of an array element. NeedsBitsizeOfPosition() bool // NeedsReadIndex specifies if the traits need the array index of the element. NeedsReadIndex() bool // PackedTraits will return the array trait as a packed object. PackedTraits() IPackedArrayTraits[T] // BitSizeOf returns the bit size of array element. If the sizee depends on // the position within the bit stream, the endBitPosition parameter is taken // into account. BitSizeOf(element T, endBitPosition int) int // InitializeOffsets returns the end bit position of an array element within // a byte stream. InitializeOffsets(bitPosition int, value T) int // Read reads an array element from a byte stream. Read(reader zserio.Reader, index int) (T, error) // Write writes an array element to a byte stream. Write(writer zserio.Writer, value T) error // AsUint64 returns the array element as a uint64. This is only needed if the // underlying data type supports delta encoding, such as int32, etc. // Other datatypes, such as string, float, can implement this empty. AsUint64(value T) uint64 // FromUint64 returns an array element from a uint64. This is only needed // if the underlying data type supports delta encoding. FromUint64(value uint64) T }
IArrayTraits is the interface used by all array traits.
type IPackedArrayTraits ¶
type IPackedArrayTraits[T any] interface { CreateContext() (*zserio.PackingContextNode, error) InitContext(contextNode *zserio.PackingContextNode, element T) error BitSizeOf(contextNode *zserio.PackingContextNode, bitPosition int, element T) (int, error) InitializeOffsets(contextNode *zserio.PackingContextNode, bitPosition int, element T) int Read(contextNode *zserio.PackingContextNode, reader zserio.Reader, index int) (T, error) Write(contextNode *zserio.PackingContextNode, writer zserio.Writer, value T) }
IPackedArrayTraits is the interface for array traits that are packed.
type ObjectArrayTraits ¶
type ObjectArrayTraits[T zserio.PackableZserioType] struct { ObjectCreator ObjectCreator[T] }
ObjectArrayTraits is an array traits for zserio structs, choice, union or enum types
func (ObjectArrayTraits[T]) AsUint64 ¶
func (trait ObjectArrayTraits[T]) AsUint64(value T) uint64
func (ObjectArrayTraits[T]) BitSizeOf ¶
func (trait ObjectArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
func (ObjectArrayTraits[T]) BitSizeOfIsConstant ¶
func (trait ObjectArrayTraits[T]) BitSizeOfIsConstant() bool
func (ObjectArrayTraits[T]) FromUint64 ¶
func (trait ObjectArrayTraits[T]) FromUint64(value uint64) T
func (ObjectArrayTraits[T]) InitializeOffsets ¶
func (trait ObjectArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
func (ObjectArrayTraits[T]) NeedsBitsizeOfPosition ¶
func (trait ObjectArrayTraits[T]) NeedsBitsizeOfPosition() bool
func (ObjectArrayTraits[T]) NeedsReadIndex ¶
func (trait ObjectArrayTraits[T]) NeedsReadIndex() bool
func (ObjectArrayTraits[T]) PackedTraits ¶
func (trait ObjectArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
type ObjectCreator ¶ added in v0.7.0
type ObjectCreator[T zserio.PackableZserioType] struct { DefaultObject T // If the @index operator is used, we need to store multiple default objects. DefaultObjects []T UsesIndexOperator bool }
type ObjectPackedArrayTraits ¶
type ObjectPackedArrayTraits[T zserio.PackableZserioType, Y IArrayTraits[T]] struct { ArrayTraits Y ObjectCreator ObjectCreator[T] }
ObjectPackedArrayTraits is a wrapper around array traits for zserio objects.
func (*ObjectPackedArrayTraits[T, Y]) BitSizeOf ¶
func (traits *ObjectPackedArrayTraits[T, Y]) BitSizeOf(contextNode *zserio.PackingContextNode, bitPosition int, element T) (int, error)
BitSizeOf returns the bit size of an element of a packed array traits.
func (*ObjectPackedArrayTraits[T, Y]) CreateContext ¶
func (traits *ObjectPackedArrayTraits[T, Y]) CreateContext() (*zserio.PackingContextNode, error)
func (*ObjectPackedArrayTraits[T, Y]) InitContext ¶
func (traits *ObjectPackedArrayTraits[T, Y]) InitContext(contextNode *zserio.PackingContextNode, element T) error
InitContext initializes a packing context for a packed array traits.
func (*ObjectPackedArrayTraits[T, Y]) InitializeOffsets ¶
func (traits *ObjectPackedArrayTraits[T, Y]) InitializeOffsets(contextNode *zserio.PackingContextNode, bitPosition int, element T) int
InitializeOffsets calculates the offsets of the packed array element.
func (*ObjectPackedArrayTraits[T, Y]) Read ¶
func (traits *ObjectPackedArrayTraits[T, Y]) Read(contextNode *zserio.PackingContextNode, reader zserio.Reader, index int) (T, error)
Read reads an array element of a packed array traits.
func (*ObjectPackedArrayTraits[T, Y]) Write ¶
func (traits *ObjectPackedArrayTraits[T, Y]) Write(contextNode *zserio.PackingContextNode, writer zserio.Writer, element T)
Write writes an array element of a packed array traits.
type OffsetMethod ¶
OffsetMethod is a function used to set/check bit offsets in the buffer.
type PackedArrayTraits ¶
type PackedArrayTraits[T any, Y IArrayTraits[T]] struct { ArrayTraits Y }
PackedArrayTraits is a wrapper around array traits used when the array is written in packed configruation.
func (*PackedArrayTraits[T, Y]) BitSizeOf ¶
func (traits *PackedArrayTraits[T, Y]) BitSizeOf(contextNode *zserio.PackingContextNode, bitPosition int, element T) (int, error)
BitSizeOf returns the bit size of an element of a packed array traits.
func (*PackedArrayTraits[T, Y]) CreateContext ¶
func (traits *PackedArrayTraits[T, Y]) CreateContext() (*zserio.PackingContextNode, error)
func (*PackedArrayTraits[T, Y]) InitContext ¶
func (traits *PackedArrayTraits[T, Y]) InitContext(contextNode *zserio.PackingContextNode, element T) error
InitContext initializes a packing context for a packed array traits.
func (*PackedArrayTraits[T, Y]) InitializeOffsets ¶
func (traits *PackedArrayTraits[T, Y]) InitializeOffsets(contextNode *zserio.PackingContextNode, bitPosition int, element T) int
InitializeOffsets calculates the offsets of the packed array element.
func (*PackedArrayTraits[T, Y]) Read ¶
func (traits *PackedArrayTraits[T, Y]) Read(contextNode *zserio.PackingContextNode, reader zserio.Reader, index int) (T, error)
Read reads an array element of a packed array traits.
func (*PackedArrayTraits[T, Y]) Write ¶
func (traits *PackedArrayTraits[T, Y]) Write(contextNode *zserio.PackingContextNode, writer zserio.Writer, value T)
Write writes an array element of a packed array traits.
type SignedBitFieldArrayTraits ¶ added in v0.6.0
type SignedBitFieldArrayTraits[T constraints.Signed] struct { NumBits uint8 }
func (SignedBitFieldArrayTraits[T]) AsUint64 ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) AsUint64(value T) uint64
func (SignedBitFieldArrayTraits[T]) BitSizeOf ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) BitSizeOf(element T, endBitPosition int) int
func (SignedBitFieldArrayTraits[T]) BitSizeOfIsConstant ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) BitSizeOfIsConstant() bool
func (SignedBitFieldArrayTraits[T]) FromUint64 ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) FromUint64(value uint64) T
func (SignedBitFieldArrayTraits[T]) InitializeOffsets ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) InitializeOffsets(bitPosition int, value T) int
func (SignedBitFieldArrayTraits[T]) NeedsBitsizeOfPosition ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) NeedsBitsizeOfPosition() bool
func (SignedBitFieldArrayTraits[T]) NeedsReadIndex ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) NeedsReadIndex() bool
func (SignedBitFieldArrayTraits[T]) PackedTraits ¶ added in v0.6.0
func (trait SignedBitFieldArrayTraits[T]) PackedTraits() IPackedArrayTraits[T]
type StringArrayTraits ¶
type StringArrayTraits struct{}
func (StringArrayTraits) AsUint64 ¶
func (trait StringArrayTraits) AsUint64(value string) uint64
func (StringArrayTraits) BitSizeOf ¶
func (trait StringArrayTraits) BitSizeOf(element string, endBitPosition int) int
func (StringArrayTraits) BitSizeOfIsConstant ¶
func (trait StringArrayTraits) BitSizeOfIsConstant() bool
func (StringArrayTraits) FromUint64 ¶
func (trait StringArrayTraits) FromUint64(value uint64) string
func (StringArrayTraits) InitializeOffsets ¶
func (trait StringArrayTraits) InitializeOffsets(bitPosition int, value string) int
func (StringArrayTraits) NeedsBitsizeOfPosition ¶
func (trait StringArrayTraits) NeedsBitsizeOfPosition() bool
func (StringArrayTraits) NeedsReadIndex ¶
func (trait StringArrayTraits) NeedsReadIndex() bool
func (StringArrayTraits) PackedTraits ¶
func (trait StringArrayTraits) PackedTraits() IPackedArrayTraits[string]
type VarInt16ArrayTraits ¶
type VarInt16ArrayTraits struct { }
VarInt16ArrayTraits is the implementation of an array traits for a VarInt16.
func (VarInt16ArrayTraits) AsUint64 ¶
func (trait VarInt16ArrayTraits) AsUint64(value int16) uint64
func (VarInt16ArrayTraits) BitSizeOf ¶
func (trait VarInt16ArrayTraits) BitSizeOf(element int16, endBitPosition int) int
func (VarInt16ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarInt16ArrayTraits) BitSizeOfIsConstant() bool
func (VarInt16ArrayTraits) FromUint64 ¶
func (trait VarInt16ArrayTraits) FromUint64(value uint64) int16
func (VarInt16ArrayTraits) InitializeOffsets ¶
func (trait VarInt16ArrayTraits) InitializeOffsets(bitPosition int, value int16) int
func (VarInt16ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarInt16ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarInt16ArrayTraits) NeedsReadIndex ¶
func (trait VarInt16ArrayTraits) NeedsReadIndex() bool
func (VarInt16ArrayTraits) PackedTraits ¶
func (trait VarInt16ArrayTraits) PackedTraits() IPackedArrayTraits[int16]
type VarInt32ArrayTraits ¶
type VarInt32ArrayTraits struct { }
VarInt32ArrayTraits is the implementation of an array traits for a VarInt32.
func (VarInt32ArrayTraits) AsUint64 ¶
func (trait VarInt32ArrayTraits) AsUint64(value int32) uint64
func (VarInt32ArrayTraits) BitSizeOf ¶
func (trait VarInt32ArrayTraits) BitSizeOf(element int32, endBitPosition int) int
func (VarInt32ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarInt32ArrayTraits) BitSizeOfIsConstant() bool
func (VarInt32ArrayTraits) FromUint64 ¶
func (trait VarInt32ArrayTraits) FromUint64(value uint64) int32
func (VarInt32ArrayTraits) InitializeOffsets ¶
func (trait VarInt32ArrayTraits) InitializeOffsets(bitPosition int, value int32) int
func (VarInt32ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarInt32ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarInt32ArrayTraits) NeedsReadIndex ¶
func (trait VarInt32ArrayTraits) NeedsReadIndex() bool
func (VarInt32ArrayTraits) PackedTraits ¶
func (trait VarInt32ArrayTraits) PackedTraits() IPackedArrayTraits[int32]
type VarInt64ArrayTraits ¶
type VarInt64ArrayTraits struct { }
VarInt64ArrayTraits is the implementation of an array traits for a VarInt64.
func (VarInt64ArrayTraits) AsUint64 ¶
func (trait VarInt64ArrayTraits) AsUint64(value int64) uint64
func (VarInt64ArrayTraits) BitSizeOf ¶
func (trait VarInt64ArrayTraits) BitSizeOf(element int64, endBitPosition int) int
func (VarInt64ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarInt64ArrayTraits) BitSizeOfIsConstant() bool
func (VarInt64ArrayTraits) FromUint64 ¶
func (trait VarInt64ArrayTraits) FromUint64(value uint64) int64
func (VarInt64ArrayTraits) InitializeOffsets ¶
func (trait VarInt64ArrayTraits) InitializeOffsets(bitPosition int, value int64) int
func (VarInt64ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarInt64ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarInt64ArrayTraits) NeedsReadIndex ¶
func (trait VarInt64ArrayTraits) NeedsReadIndex() bool
func (VarInt64ArrayTraits) PackedTraits ¶
func (trait VarInt64ArrayTraits) PackedTraits() IPackedArrayTraits[int64]
type VarIntArrayTraits ¶
type VarIntArrayTraits struct { }
VarIntArrayTraits is an array traits implementation for VarInt.
func (VarIntArrayTraits) AsUint64 ¶
func (trait VarIntArrayTraits) AsUint64(value int64) uint64
func (VarIntArrayTraits) BitSizeOf ¶
func (trait VarIntArrayTraits) BitSizeOf(element int64, endBitPosition int) int
func (VarIntArrayTraits) BitSizeOfIsConstant ¶
func (trait VarIntArrayTraits) BitSizeOfIsConstant() bool
func (VarIntArrayTraits) FromUint64 ¶
func (trait VarIntArrayTraits) FromUint64(value uint64) int64
func (VarIntArrayTraits) InitializeOffsets ¶
func (trait VarIntArrayTraits) InitializeOffsets(bitPosition int, value int64) int
func (VarIntArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarIntArrayTraits) NeedsBitsizeOfPosition() bool
func (VarIntArrayTraits) NeedsReadIndex ¶
func (trait VarIntArrayTraits) NeedsReadIndex() bool
func (VarIntArrayTraits) PackedTraits ¶
func (trait VarIntArrayTraits) PackedTraits() IPackedArrayTraits[int64]
type VarSizeArrayTraits ¶
type VarSizeArrayTraits struct{}
func (VarSizeArrayTraits) AsUint64 ¶
func (trait VarSizeArrayTraits) AsUint64(value uint64) uint64
func (VarSizeArrayTraits) BitSizeOf ¶
func (trait VarSizeArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
func (VarSizeArrayTraits) BitSizeOfIsConstant ¶
func (trait VarSizeArrayTraits) BitSizeOfIsConstant() bool
func (VarSizeArrayTraits) FromUint64 ¶
func (trait VarSizeArrayTraits) FromUint64(value uint64) uint64
func (VarSizeArrayTraits) InitializeOffsets ¶
func (trait VarSizeArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
func (VarSizeArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarSizeArrayTraits) NeedsBitsizeOfPosition() bool
func (VarSizeArrayTraits) NeedsReadIndex ¶
func (trait VarSizeArrayTraits) NeedsReadIndex() bool
func (VarSizeArrayTraits) PackedTraits ¶
func (trait VarSizeArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
type VarUInt16ArrayTraits ¶
type VarUInt16ArrayTraits struct { }
VarUInt16ArrayTraits is the implementation of an array traits for a VarUint16.
func (VarUInt16ArrayTraits) AsUint64 ¶
func (trait VarUInt16ArrayTraits) AsUint64(value uint16) uint64
func (VarUInt16ArrayTraits) BitSizeOf ¶
func (trait VarUInt16ArrayTraits) BitSizeOf(element uint16, endBitPosition int) int
func (VarUInt16ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarUInt16ArrayTraits) BitSizeOfIsConstant() bool
func (VarUInt16ArrayTraits) FromUint64 ¶
func (trait VarUInt16ArrayTraits) FromUint64(value uint64) uint16
func (VarUInt16ArrayTraits) InitializeOffsets ¶
func (trait VarUInt16ArrayTraits) InitializeOffsets(bitPosition int, value uint16) int
func (VarUInt16ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarUInt16ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarUInt16ArrayTraits) NeedsReadIndex ¶
func (trait VarUInt16ArrayTraits) NeedsReadIndex() bool
func (VarUInt16ArrayTraits) PackedTraits ¶
func (trait VarUInt16ArrayTraits) PackedTraits() IPackedArrayTraits[uint16]
type VarUInt32ArrayTraits ¶
type VarUInt32ArrayTraits struct { }
func (VarUInt32ArrayTraits) AsUint64 ¶
func (trait VarUInt32ArrayTraits) AsUint64(value uint32) uint64
func (VarUInt32ArrayTraits) BitSizeOf ¶
func (trait VarUInt32ArrayTraits) BitSizeOf(element uint32, endBitPosition int) int
func (VarUInt32ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarUInt32ArrayTraits) BitSizeOfIsConstant() bool
func (VarUInt32ArrayTraits) FromUint64 ¶
func (trait VarUInt32ArrayTraits) FromUint64(value uint64) uint32
func (VarUInt32ArrayTraits) InitializeOffsets ¶
func (trait VarUInt32ArrayTraits) InitializeOffsets(bitPosition int, value uint32) int
func (VarUInt32ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarUInt32ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarUInt32ArrayTraits) NeedsReadIndex ¶
func (trait VarUInt32ArrayTraits) NeedsReadIndex() bool
func (VarUInt32ArrayTraits) PackedTraits ¶
func (trait VarUInt32ArrayTraits) PackedTraits() IPackedArrayTraits[uint32]
type VarUInt64ArrayTraits ¶
type VarUInt64ArrayTraits struct { }
func (VarUInt64ArrayTraits) AsUint64 ¶
func (trait VarUInt64ArrayTraits) AsUint64(value uint64) uint64
func (VarUInt64ArrayTraits) BitSizeOf ¶
func (trait VarUInt64ArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
func (VarUInt64ArrayTraits) BitSizeOfIsConstant ¶
func (trait VarUInt64ArrayTraits) BitSizeOfIsConstant() bool
func (VarUInt64ArrayTraits) FromUint64 ¶
func (trait VarUInt64ArrayTraits) FromUint64(value uint64) uint64
func (VarUInt64ArrayTraits) InitializeOffsets ¶
func (trait VarUInt64ArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
func (VarUInt64ArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarUInt64ArrayTraits) NeedsBitsizeOfPosition() bool
func (VarUInt64ArrayTraits) NeedsReadIndex ¶
func (trait VarUInt64ArrayTraits) NeedsReadIndex() bool
func (VarUInt64ArrayTraits) PackedTraits ¶
func (trait VarUInt64ArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
type VarUIntArrayTraits ¶
type VarUIntArrayTraits struct{}
func (VarUIntArrayTraits) AsUint64 ¶
func (trait VarUIntArrayTraits) AsUint64(value uint64) uint64
func (VarUIntArrayTraits) BitSizeOf ¶
func (trait VarUIntArrayTraits) BitSizeOf(element uint64, endBitPosition int) int
func (VarUIntArrayTraits) BitSizeOfIsConstant ¶
func (trait VarUIntArrayTraits) BitSizeOfIsConstant() bool
func (VarUIntArrayTraits) FromUint64 ¶
func (trait VarUIntArrayTraits) FromUint64(value uint64) uint64
func (VarUIntArrayTraits) InitializeOffsets ¶
func (trait VarUIntArrayTraits) InitializeOffsets(bitPosition int, value uint64) int
func (VarUIntArrayTraits) NeedsBitsizeOfPosition ¶
func (trait VarUIntArrayTraits) NeedsBitsizeOfPosition() bool
func (VarUIntArrayTraits) NeedsReadIndex ¶
func (trait VarUIntArrayTraits) NeedsReadIndex() bool
func (VarUIntArrayTraits) PackedTraits ¶
func (trait VarUIntArrayTraits) PackedTraits() IPackedArrayTraits[uint64]
Source Files ¶
- array.go
- array_decode.go
- array_encode.go
- array_traits.go
- bit_alignment.go
- bits_decode.go
- bits_encode.go
- bool_decode.go
- bool_encode.go
- bytes.go
- bytes_decode.go
- bytes_encode.go
- delta_context.go
- doc.go
- extern.go
- extern_decode.go
- extern_encode.go
- float_decode.go
- float_encode.go
- limits.go
- packed_array_traits.go
- packing_context_node.go
- string_decode.go
- string_encode.go
- varint_decode.go
- varint_encode.go
- varuint_decode.go
- varuint_encode.go