access

package
v0.1.1-rc.15 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderTagSize = 2

Variables

This section is empty.

Functions

func Decode

func Decode(buf []byte) (any, error)

Decode: convenience entry point for decoding a buffer that contains a top-level tuple. Decode decodes a buffer into Go values. Maps inside tuples are decoded as plain map[string]any.

func DecodeMapAny

func DecodeMapAny(seq *SeqGetAccess) (map[string]any, error)

DecodeMapAny: decode a map[string]any from the current position in a SeqGetAccess.

func DecodeOrdered

func DecodeOrdered(buf []byte) (any, error)

DecodeOrdered decodes a buffer into Go values. Maps inside tuples are decoded as *typetags.OrderedMapAny.

func DecodeOrderedMapAny

func DecodeOrderedMapAny(seq *SeqGetAccess) (*typetags.OrderedMapAny, error)

DecodeOrderedMapAny decodes a map from the sequence into an OrderedMapAny, preserving insertion order of keys.

func DecodePrimitive

func DecodePrimitive(typ typetags.Type, buf []byte) (interface{}, error)

DecodePrimitive interprets a primitive payload directly using type tag and width. It returns a Go value (int, float, string, []byte as string, bool, nil).

func DecodeTuple

func DecodeTuple(seq *SeqGetAccess) ([]any, error)

Convenience wrappers

func DecodeTupleGeneric

func DecodeTupleGeneric(seq *SeqGetAccess, root bool, ordered bool) ([]any, error)

DecodeTupleGeneric: decode a []any from the current position in a SeqGetAccess. If root is true, the caller already consumed the tuple header. If ordered is true, maps inside the tuple are decoded as *typetags.OrderedMapAny.

func DecodeTupleOrdered

func DecodeTupleOrdered(seq *SeqGetAccess) ([]any, error)

func GetAny

func GetAny(g *GetAccess, pos int) (any, error)

func ReleasePutAccess

func ReleasePutAccess(pa *PutAccess)

func WriteBool

func WriteBool(buffer []byte, pos int, v bool) int

WriteBool writes a boolean value as a single byte to the buffer.

func WriteBytes

func WriteBytes(buffer []byte, pos int, b []byte) int

WriteBytes writes a byte slice to the buffer.

func WriteFloat32

func WriteFloat32(buffer []byte, pos int, v float32) int

WriteFloat32 writesa float32 to the buffer.

func WriteFloat64

func WriteFloat64(buffer []byte, pos int, v float64) int

WriteFloat64 writesa float64 to the buffer.

func WriteInt8

func WriteInt8(buffer []byte, pos int, v int8) int

WriteInt8 writes an int8 value to the buffer.

func WriteInt16

func WriteInt16(buffer []byte, pos int, v int16) int

WriteInt16 writes an int16 value to the buffer.

func WriteInt32

func WriteInt32(buffer []byte, pos int, v int32) int

WriteInt32 writes an int32 value to the buffer.

func WriteInt64

func WriteInt64(buffer []byte, pos int, v int64) int

WriteInt64 writes an int64 value to the buffer.

func WriteNullableBool

func WriteNullableBool(buffer []byte, pos int, v *bool) int

WriteNullableBool writes a pointer to a boolean to the buffer.

func WriteNullableFloat32

func WriteNullableFloat32(buffer []byte, pos int, v *float32) int

WriteNullableFloat32 writes a pointer to a float32 to the buffer.

func WriteNullableFloat64

func WriteNullableFloat64(buffer []byte, pos int, v *float64) int

WriteNullableFloat64 writes a pointer to a float64 to the buffer.

func WriteNullableInt8

func WriteNullableInt8(buffer []byte, pos int, v *int8) int

WriteNullableInt8 writes a pointer to an int8 to the buffer.

func WriteNullableInt16

func WriteNullableInt16(buffer []byte, pos int, v *int16) int

WriteNullableInt16 writes a pointer to an int16 to the buffer.

func WriteNullableInt32

func WriteNullableInt32(buffer []byte, pos int, v *int32) int

WriteNullableInt32 writes a pointer to an int32 to the buffer.

func WriteNullableInt64

func WriteNullableInt64(buffer []byte, pos int, v *int64) int

WriteNullableInt64 writes a pointer to an int64 to the buffer.

func WriteNullableUint8

func WriteNullableUint8(buffer []byte, pos int, v *uint8) int

WriteNullableUint8 writes a pointer to a uint8 to the buffer.

func WriteNullableUint16

func WriteNullableUint16(buffer []byte, pos int, v *uint16) int

WriteNullableUint16 writes a pointer to a uint16 to the buffer.

func WriteNullableUint32

func WriteNullableUint32(buffer []byte, pos int, v *uint32) int

WriteNullableUint32 writes a pointer to a uint32 to the buffer.

func WriteNullableUint64

func WriteNullableUint64(buffer []byte, pos int, v *uint64) int

WriteNullableUint64 writes a pointer to a uint64 to the buffer.

func WriteString

func WriteString(buffer []byte, pos int, s string) int

WriteString writes a string to the buffer.

func WriteTypeHeader

func WriteTypeHeader(buffer []byte, pos int, encodedPos int, t typetags.Type) (newPos int)

WriteTypeHeader writes a header to the buffer at pos and returns the new position.

func WriteUint8

func WriteUint8(buffer []byte, pos int, v uint8) int

WriteUint8 writes a uint8 value to the buffer.

func WriteUint16

func WriteUint16(buffer []byte, pos int, v uint16) int

WriteUint16 writes a uint16 value to the buffer.

func WriteUint32

func WriteUint32(buffer []byte, pos int, v uint32) int

WriteUint32 writes a uint32 value to the buffer.

func WriteUint64

func WriteUint64(buffer []byte, pos int, v uint64) int

WriteUint64 writes a uint64 value to the buffer.

Types

type GetAccess

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

func NewGetAccess

func NewGetAccess(buf []byte) *GetAccess

func (*GetAccess) GetAsPackable

func (g *GetAccess) GetAsPackable(pos int) (Packable, error)

func (*GetAccess) GetBool

func (g *GetAccess) GetBool(pos int) (bool, error)

func (*GetAccess) GetBytes

func (g *GetAccess) GetBytes(pos int) ([]byte, error)

GetBytes decodes a byte slice at position pos

func (*GetAccess) GetCopyBytes

func (g *GetAccess) GetCopyBytes(pos int) ([]byte, error)

GetCopyBytes decodes and returns a fresh copy of the byte slice. Use this to avoid retention of the entire GetAccess buffer in memory, which prevents the garbage collector from reclaiming the large backing array.

func (*GetAccess) GetFloat32

func (g *GetAccess) GetFloat32(pos int) (float32, error)

GetFloat32 decodes a float32 at position pos

func (*GetAccess) GetFloat64

func (g *GetAccess) GetFloat64(pos int) (float64, error)

GetFloat64 decodes a float64 at position pos

func (*GetAccess) GetFloating

func (g *GetAccess) GetFloating(pos int) (any, int, error)

func (*GetAccess) GetInt

func (g *GetAccess) GetInt(pos int) (any, int, error)

func (*GetAccess) GetInt8

func (g *GetAccess) GetInt8(pos int) (int8, error)

func (*GetAccess) GetInt16

func (g *GetAccess) GetInt16(pos int) (int16, error)

func (*GetAccess) GetInt32

func (g *GetAccess) GetInt32(pos int) (int32, error)

func (*GetAccess) GetInt64

func (g *GetAccess) GetInt64(pos int) (int64, error)

func (*GetAccess) GetMapAny

func (g *GetAccess) GetMapAny(pos int) (map[string]any, error)

func (*GetAccess) GetMapOrderedAny

func (g *GetAccess) GetMapOrderedAny(pos int) (*typetags.OrderedMapAny, error)

GetMapOrderedAny decodes a map at the given position into an OrderedMapAny, preserving insertion order of keys.

func (*GetAccess) GetMapStr

func (g *GetAccess) GetMapStr(pos int) (map[string]string, error)

func (*GetAccess) GetNestedGetAccess

func (g *GetAccess) GetNestedGetAccess(pos int) (*GetAccess, typetags.Type, error)

func (*GetAccess) GetNullableBool

func (g *GetAccess) GetNullableBool(pos int) (*bool, error)

func (*GetAccess) GetNullableFloat32

func (g *GetAccess) GetNullableFloat32(pos int) (*float32, error)

GetNullableFloat32 decodes a nullable float32 at position pos

func (*GetAccess) GetNullableFloat64

func (g *GetAccess) GetNullableFloat64(pos int) (*float64, error)

GetNullableFloat64 decodes a nullable float64 at position pos

func (*GetAccess) GetNullableInt8

func (g *GetAccess) GetNullableInt8(pos int) (*int8, error)

func (*GetAccess) GetNullableInt16

func (g *GetAccess) GetNullableInt16(pos int) (*int16, error)

func (*GetAccess) GetNullableInt32

func (g *GetAccess) GetNullableInt32(pos int) (*int32, error)

func (*GetAccess) GetNullableInt64

func (g *GetAccess) GetNullableInt64(pos int) (*int64, error)

func (*GetAccess) GetNullableUint8

func (g *GetAccess) GetNullableUint8(pos int) (*uint8, error)

func (*GetAccess) GetNullableUint16

func (g *GetAccess) GetNullableUint16(pos int) (*uint16, error)

func (*GetAccess) GetNullableUint32

func (g *GetAccess) GetNullableUint32(pos int) (*uint32, error)

func (*GetAccess) GetNullableUint64

func (g *GetAccess) GetNullableUint64(pos int) (*uint64, error)

func (*GetAccess) GetString

func (g *GetAccess) GetString(pos int) (string, error)

GetString decodes a string at position pos

func (*GetAccess) GetStringUnsafe

func (g *GetAccess) GetStringUnsafe(pos int) (string, error)

GetStringUnsafe decodes a string at position pos using unsafe.String

func (*GetAccess) GetTypeAndValue

func (g *GetAccess) GetTypeAndValue(pos int) (typetags.Type, []byte)

function to get type and value, which can be used for repacking or other purposes

func (*GetAccess) GetUint8

func (g *GetAccess) GetUint8(pos int) (uint8, error)

func (*GetAccess) GetUint16

func (g *GetAccess) GetUint16(pos int) (uint16, error)

GetUint16 decodes a uint16 at position pos

func (*GetAccess) GetUint32

func (g *GetAccess) GetUint32(pos int) (uint32, error)

GetUint32 decodes a uint32 at position pos

func (*GetAccess) GetUint64

func (g *GetAccess) GetUint64(pos int) (uint64, error)

GetUint64 decodes a uint64 at position pos

type Packable

type Packable interface {
	HeaderType() typetags.Type
	ValueSize() int
	Write(buf []byte, pos int) int
	// dymanic way of adding to the putAccess
	PackInto(p *PutAccess)
}

type PackableTagValue

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

func (*PackableTagValue) HeaderType

func (px *PackableTagValue) HeaderType() typetags.Type

func (*PackableTagValue) PackInto

func (px *PackableTagValue) PackInto(p *PutAccess)

func (*PackableTagValue) ValueSize

func (px *PackableTagValue) ValueSize() int

func (*PackableTagValue) Write

func (px *PackableTagValue) Write(buf []byte, pos int) int

type PutAccess

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

func GetPutAccess

func GetPutAccess() *PutAccess

func GetPutAccessZero

func GetPutAccessZero() *PutAccess

func NewPutAccess

func NewPutAccess() *PutAccess

func NewPutAccessFromPool

func NewPutAccessFromPool() *PutAccess

func NewPutAccessFromPoolZero

func NewPutAccessFromPoolZero() *PutAccess

func (*PutAccess) AddAny

func (p *PutAccess) AddAny(m any, useNumeric bool) error

func (*PutAccess) AddAnyTuple

func (p *PutAccess) AddAnyTuple(m []interface{}, useNumeric bool) error

func (*PutAccess) AddAnyTupleSortedMap

func (p *PutAccess) AddAnyTupleSortedMap(m []interface{}, useNumeric bool) error

func (*PutAccess) AddBool

func (p *PutAccess) AddBool(b bool)

AddBool packs a boolean value as a single byte

func (*PutAccess) AddBytes

func (p *PutAccess) AddBytes(b []byte)

func (*PutAccess) AddFloat32

func (p *PutAccess) AddFloat32(v float32)

func (*PutAccess) AddFloat64

func (p *PutAccess) AddFloat64(v float64)

func (*PutAccess) AddInt8

func (p *PutAccess) AddInt8(b int8)

AddInt8 packs a boolean value as a single byte

func (*PutAccess) AddInt16

func (p *PutAccess) AddInt16(v int16)

func (*PutAccess) AddInt32

func (p *PutAccess) AddInt32(v int32)

func (*PutAccess) AddInt64

func (p *PutAccess) AddInt64(v int64)

func (*PutAccess) AddIntegerCompressed

func (p *PutAccess) AddIntegerCompressed(val int64)

func (*PutAccess) AddMap

func (p *PutAccess) AddMap(m map[string][]byte)

func (*PutAccess) AddMapAny

func (p *PutAccess) AddMapAny(m map[string]any, useNumeric bool) error

func (*PutAccess) AddMapAnyOrdered

func (p *PutAccess) AddMapAnyOrdered(om *typetags.OrderedMap[any], useNumeric bool) error

AddMapAnyOrdered encodes an OrderedMap[string→any] preserving insertion order.

func (*PutAccess) AddMapAnySortedKey

func (p *PutAccess) AddMapAnySortedKey(m map[string]any, useNumeric bool) error

func (*PutAccess) AddMapSortedKey

func (p *PutAccess) AddMapSortedKey(m map[string][]byte)

func (*PutAccess) AddMapSortedKeyStr

func (p *PutAccess) AddMapSortedKeyStr(m map[string]string)

func (*PutAccess) AddMapStr

func (p *PutAccess) AddMapStr(m map[string]string)

func (*PutAccess) AddNull

func (p *PutAccess) AddNull(m []interface{})

func (*PutAccess) AddNullableBool

func (p *PutAccess) AddNullableBool(v *bool)

func (*PutAccess) AddNullableFloat32

func (p *PutAccess) AddNullableFloat32(v *float32)

func (*PutAccess) AddNullableFloat64

func (p *PutAccess) AddNullableFloat64(v *float64)

func (*PutAccess) AddNullableInt8

func (p *PutAccess) AddNullableInt8(v *int8)

func (*PutAccess) AddNullableInt16

func (p *PutAccess) AddNullableInt16(v *int16)

func (*PutAccess) AddNullableInt32

func (p *PutAccess) AddNullableInt32(v *int32)

func (*PutAccess) AddNullableInt64

func (p *PutAccess) AddNullableInt64(v *int64)

func (*PutAccess) AddNullableUint8

func (p *PutAccess) AddNullableUint8(v *uint8)

func (*PutAccess) AddNullableUint16

func (p *PutAccess) AddNullableUint16(v *uint16)

func (*PutAccess) AddNullableUint32

func (p *PutAccess) AddNullableUint32(v *uint32)

func (*PutAccess) AddNullableUint64

func (p *PutAccess) AddNullableUint64(v *uint64)

func (*PutAccess) AddNumeric

func (p *PutAccess) AddNumeric(v float64)

AddNumeric chooses the smallest fitting integer type if v is integral, otherwise stores it as a float64.

func (*PutAccess) AddNumericString

func (p *PutAccess) AddNumericString(val string) error

func (*PutAccess) AddPackable

func (p *PutAccess) AddPackable(v Packable)

func (*PutAccess) AddString

func (p *PutAccess) AddString(s string)

func (*PutAccess) AddStringArray

func (p *PutAccess) AddStringArray(arr []string)

AddStringArray packs a []string as a tuple

func (*PutAccess) AddUint8

func (p *PutAccess) AddUint8(b uint8)

AddUint8 packs a boolean value as a single byte

func (*PutAccess) AddUint16

func (p *PutAccess) AddUint16(v uint16)

AddUint16 packs a uint16 value.

func (*PutAccess) AddUint32

func (p *PutAccess) AddUint32(v uint32)

AddUint32 packs a uint32 value.

func (*PutAccess) AddUint64

func (p *PutAccess) AddUint64(v uint64)

AddUint64 packs a uint64 value.

func (*PutAccess) AddUnsignedCompressed

func (p *PutAccess) AddUnsignedCompressed(val uint64)

func (*PutAccess) AppendTagAndValue

func (p *PutAccess) AppendTagAndValue(tag typetags.Type, val []byte)

func (*PutAccess) BeginMap

func (p *PutAccess) BeginMap() *PutAccess

func (*PutAccess) BeginTuple

func (p *PutAccess) BeginTuple() *PutAccess

func (*PutAccess) EndNested

func (p *PutAccess) EndNested(nested *PutAccess)

func (*PutAccess) Pack

func (p *PutAccess) Pack() []byte

func (*PutAccess) PackAppend

func (p *PutAccess) PackAppend(buf []byte) []byte

func (*PutAccess) PackBuff

func (p *PutAccess) PackBuff(buffer []byte) (int, error)

func (*PutAccess) PackSize

func (p *PutAccess) PackSize() int

Call it before Pack. Pack adds +2

type SeqGetAccess

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

func NewSeqGetAccess

func NewSeqGetAccess(buf []byte) (*SeqGetAccess, error)

func (*SeqGetAccess) Advance

func (s *SeqGetAccess) Advance() error

func (*SeqGetAccess) ArgCount

func (s *SeqGetAccess) ArgCount() int

func (*SeqGetAccess) CurrentIndex

func (s *SeqGetAccess) CurrentIndex() int

func (*SeqGetAccess) GetPayload

func (s *SeqGetAccess) GetPayload(width int) ([]byte, error)

func (*SeqGetAccess) Next

func (s *SeqGetAccess) Next() ([]byte, typetags.Type, error)

func (*SeqGetAccess) NextOffsetWidth

func (s *SeqGetAccess) NextOffsetWidth() (int, int, typetags.Type, error)

func (*SeqGetAccess) PeekNestedSeq

func (s *SeqGetAccess) PeekNestedSeq() (*SeqGetAccess, error)

func (*SeqGetAccess) PeekTypeWidth

func (s *SeqGetAccess) PeekTypeWidth() (typetags.Type, int, error)

func (*SeqGetAccess) UnderlineBuffer

func (s *SeqGetAccess) UnderlineBuffer() []byte

Jump to

Keyboard shortcuts

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