plenccodec

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 14 Imported by: 3

Documentation

Overview

Package plenccodec provides the core Codecs for plenc.

You shouldn't need to interact with this package directly unless you're building your own custom codecs.

The exception to this is the Descriptor endpoint on a Codec. This is a serialisable description that allows you to decode plenc data without the type that the data was encoded from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BQTimestampCodec added in v0.0.13

type BQTimestampCodec struct {
	FlatIntCodec[uint64]
}

BQTimestampStruct encodes a time.Time as a flat (not zigzag) int64 of microseconds since the Epoch. This is how the BigQuery write API expects a timestamp to be encoded

func (BQTimestampCodec) Append added in v0.0.13

func (c BQTimestampCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (BQTimestampCodec) Descriptor added in v0.0.14

func (c BQTimestampCodec) Descriptor() Descriptor

func (BQTimestampCodec) New added in v0.0.13

func (BQTimestampCodec) Omit added in v0.0.13

func (BQTimestampCodec) Omit(ptr unsafe.Pointer) bool

func (BQTimestampCodec) Read added in v0.0.13

func (c BQTimestampCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

type BaseSliceWrapper

type BaseSliceWrapper struct {
	Underlying Codec
	EltSize    uintptr
	EltType    unsafe.Pointer
}

func (BaseSliceWrapper) Descriptor

func (c BaseSliceWrapper) Descriptor() Descriptor

func (BaseSliceWrapper) New

func (BaseSliceWrapper) Omit

func (c BaseSliceWrapper) Omit(ptr unsafe.Pointer) bool

func (BaseSliceWrapper) WireType

func (c BaseSliceWrapper) WireType() plenccore.WireType

type BoolCodec

type BoolCodec struct{}

BoolCodec is a codec for a bool

func (BoolCodec) Append

func (c BoolCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (BoolCodec) Descriptor

func (c BoolCodec) Descriptor() Descriptor

func (BoolCodec) New

func (c BoolCodec) New() unsafe.Pointer

New creates a pointer to a new bool

func (BoolCodec) Omit

func (c BoolCodec) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (BoolCodec) Read

func (BoolCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a bool

func (BoolCodec) Size

func (c BoolCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (BoolCodec) WireType

func (c BoolCodec) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type BytesCodec

type BytesCodec struct{}

BytesCodec is a codec for a byte slice

func (BytesCodec) Append

func (c BytesCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (BytesCodec) Descriptor

func (BytesCodec) Descriptor() Descriptor

func (BytesCodec) New

func (c BytesCodec) New() unsafe.Pointer

New creates a pointer to a new bool

func (BytesCodec) Omit

func (c BytesCodec) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (BytesCodec) Read

func (BytesCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a []byte

func (BytesCodec) Size

func (c BytesCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (BytesCodec) WireType

func (c BytesCodec) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type Codec

type Codec interface {
	Omit(ptr unsafe.Pointer) bool
	Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)
	New() unsafe.Pointer
	WireType() plenccore.WireType

	// Descriptor returns a descriptor for the type correspondng to the Codec.
	// The descriptor can be used to interpret plenc data without access to the
	// original type. The descriptor can also be serialised (either as JSON or
	// plenc), so can be stored or communicated with another system
	Descriptor() Descriptor

	// Size returns the size of the encoded data including the tag and
	// for WTLength types the varint encoded length of the data. If the tag is
	// nil then it is not included in the size and neither is the length for
	// WTLength types
	Size(ptr unsafe.Pointer, tag []byte) int

	// Append appends the encoded data including the tag and for WTLength
	// types the varint encoded length of the data. If the tag is nil then it is
	// not included in the data and neither is the length for WTLength types
	Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte
}

Codec is what you implement to encode / decode a type. Note that codecs are separate from the types they encode, and that they are registered with the system via RegisterCodec.

It isn't normally necessary to build a codec for a struct. Codecs for structs are generated automatically when plenc first sees them and then are re-used for the life of the program.

func BuildMapCodec

func BuildMapCodec(p CodecBuilder, registry CodecRegistry, typ reflect.Type, tag string) (Codec, error)

func BuildStructCodec

func BuildStructCodec(p CodecBuilder, registry CodecRegistry, typ reflect.Type, tag string) (Codec, error)

type CodecBuilder added in v0.0.5

type CodecBuilder interface {
	// CodecForTypeRegistry builds a new codec for the requested type,
	// consulting registry for any existing codecs needed
	CodecForTypeRegistry(registry CodecRegistry, typ reflect.Type, tag string) (Codec, error)
}

CodecBuilder either builds a new codec for a type, or finds an existing codec

type CodecRegistry added in v0.0.5

type CodecRegistry interface {
	// Load loads the codec from the registry. It returns nil if no codec exists
	Load(typ reflect.Type, tag string) Codec
	// StoreOrSwap adds the codec to the registry. It may return a different
	// codec if the codec has been built on another goroutine
	StoreOrSwap(typ reflect.Type, tag string, c Codec) Codec
}

CodecRegistry is a repository of pre-existing Codecs

type Descriptor

type Descriptor struct {
	// Index is the plenc index of this field
	Index int `plenc:"1"`
	// Name is the name of the field
	Name string `plenc:"2"`
	// Type is the type of the field
	Type FieldType `plenc:"3"`
	// TypeName is used for struct types and is the name of the struct.
	TypeName string `plenc:"5"`
	// Elements is valid for FieldTypeSlice, FieldTypeStruct & FieldTypeMap. For
	// FieldTypeSlice we expect one entry that describes the elements of the
	// slice. For FieldTypeStruct we expect an entry for each field in the
	// struct. For FieldTypeMap we expect two entries. The first is for the key
	// type and the second is for the map type
	Elements []Descriptor `plenc:"4"`

	// ExplicitPresence is set if the field has a mechanism to distinguish when
	// it is not present. So either a pointer type or something from the null
	// package. If this is not set then a missing value indicates the zero
	// value, not a null or nil entry.
	ExplicitPresence bool `plenc:"6"`

	// The logical type of the field. This is used to indicate if the field has
	// any special meaning - e.g. if a long or string indicates a timestamp.
	LogicalType LogicalType `plenc:"7"`
}

Descriptor describes how a type is plenc-encoded. It contains enough information to decode plenc data marshalled from the described type.

func (*Descriptor) Read

func (d *Descriptor) Read(out Outputter, data []byte) (err error)

type FieldType

type FieldType int
const (
	FieldTypeInt FieldType = iota
	FieldTypeUint
	FieldTypeFloat32
	FieldTypeFloat64
	FieldTypeString
	FieldTypeSlice
	FieldTypeStruct
	FieldTypeBool
	FieldTypeTime
	FieldTypeJSONObject
	FieldTypeJSONArray
	// Not zig-zag encoded, but expected to be signed. Don't use if negative
	// numbers are likely.
	FieldTypeFlatInt
)

func (FieldType) String

func (i FieldType) String() string

type FlatIntCodec added in v0.0.13

type FlatIntCodec[T uint | uint8 | uint16 | uint32 | uint64] struct {
	UintCodec[T]
}

FlatIntCodec is for signed ints that aren't zig-zag encoded. Use this with ints that are almost always positive.

func (FlatIntCodec[T]) Descriptor added in v0.0.13

func (c FlatIntCodec[T]) Descriptor() Descriptor

type Float32Codec

type Float32Codec struct{}

Float32Codec is a coddec for a float32

func (Float32Codec) Append

func (c Float32Codec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (Float32Codec) Descriptor

func (c Float32Codec) Descriptor() Descriptor

func (Float32Codec) New

func (c Float32Codec) New() unsafe.Pointer

New creates a pointer to a new float32

func (Float32Codec) Omit

func (c Float32Codec) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (Float32Codec) Read

func (Float32Codec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a float32

func (Float32Codec) Size

func (c Float32Codec) Size(ptr unsafe.Pointer, tag []byte) int

func (Float32Codec) WireType

func (c Float32Codec) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type Float64Codec

type Float64Codec struct{}

Float64Codec is a coddec for a float64

func (Float64Codec) Append

func (c Float64Codec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (Float64Codec) Descriptor

func (c Float64Codec) Descriptor() Descriptor

func (Float64Codec) New

func (c Float64Codec) New() unsafe.Pointer

New creates a pointer to a new float64

func (Float64Codec) Omit

func (c Float64Codec) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (Float64Codec) Read

func (Float64Codec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a float64

func (Float64Codec) Size

func (c Float64Codec) Size(ptr unsafe.Pointer, tag []byte) int

func (Float64Codec) WireType

func (c Float64Codec) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type IntCodec

type IntCodec[T int | int8 | int16 | int32 | int64] struct{}

IntCodec is a coddec for an int

func (IntCodec[T]) Append

func (c IntCodec[T]) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (IntCodec[T]) Descriptor

func (c IntCodec[T]) Descriptor() Descriptor

func (IntCodec[T]) New

func (c IntCodec[T]) New() unsafe.Pointer

New creates a pointer to a new Int

func (IntCodec[T]) Omit

func (c IntCodec[T]) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (IntCodec[T]) Read

func (IntCodec[T]) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a Int

func (IntCodec[T]) Size

func (c IntCodec[T]) Size(ptr unsafe.Pointer, tag []byte) int

func (IntCodec[T]) WireType

func (c IntCodec[T]) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type InternedStringCodec

type InternedStringCodec struct {
	sync.Mutex

	StringCodec
	// contains filtered or unexported fields
}

func (*InternedStringCodec) Read

func (c *InternedStringCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

type Interner

type Interner interface {
	WithInterning() Codec
}

type JSONArrayCodec

type JSONArrayCodec struct{}

JSONArrayCodec is for serialising JSON arrays encoded as []any

func (JSONArrayCodec) Append

func (c JSONArrayCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (JSONArrayCodec) Descriptor

func (c JSONArrayCodec) Descriptor() Descriptor

func (JSONArrayCodec) New

func (c JSONArrayCodec) New() unsafe.Pointer

func (JSONArrayCodec) Omit

func (c JSONArrayCodec) Omit(ptr unsafe.Pointer) bool

func (JSONArrayCodec) Read

func (c JSONArrayCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (JSONArrayCodec) Size

func (c JSONArrayCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (JSONArrayCodec) WireType

func (c JSONArrayCodec) WireType() plenccore.WireType

type JSONMapCodec

type JSONMapCodec struct{}

JSONMapCodec is for serialising JSON maps encoded in Go as map[string]any. To use this codec you must register it for use with map[string]any or a named map[string]any type

func (JSONMapCodec) Append

func (c JSONMapCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (JSONMapCodec) Descriptor

func (c JSONMapCodec) Descriptor() Descriptor

func (JSONMapCodec) New

func (c JSONMapCodec) New() unsafe.Pointer

func (JSONMapCodec) Omit

func (JSONMapCodec) Omit(ptr unsafe.Pointer) bool

func (JSONMapCodec) Read

func (c JSONMapCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (JSONMapCodec) Size

func (c JSONMapCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (JSONMapCodec) WireType

func (c JSONMapCodec) WireType() plenccore.WireType

type JSONOutput

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

JSONOutput converts Descriptor output to JSON.

func (*JSONOutput) Bool

func (j *JSONOutput) Bool(v bool)

func (*JSONOutput) Done

func (j *JSONOutput) Done() []byte

func (*JSONOutput) EndArray

func (j *JSONOutput) EndArray()

func (*JSONOutput) EndObject

func (j *JSONOutput) EndObject()

func (*JSONOutput) Float32

func (j *JSONOutput) Float32(v float32)

func (*JSONOutput) Float64

func (j *JSONOutput) Float64(v float64)

func (*JSONOutput) Int64

func (j *JSONOutput) Int64(v int64)

func (*JSONOutput) NameField

func (j *JSONOutput) NameField(name string)

func (*JSONOutput) Raw

func (j *JSONOutput) Raw(v string)

func (*JSONOutput) Reset

func (j *JSONOutput) Reset()

func (*JSONOutput) StartArray

func (j *JSONOutput) StartArray()

func (*JSONOutput) StartObject

func (j *JSONOutput) StartObject()

func (*JSONOutput) String

func (j *JSONOutput) String(v string)

func (*JSONOutput) Time

func (j *JSONOutput) Time(t time.Time)

func (*JSONOutput) Uint64

func (j *JSONOutput) Uint64(v uint64)

type LogicalType added in v0.0.14

type LogicalType int
const (
	LogicalTypeNone LogicalType = iota
	LogicalTypeTimestamp
	LogicalTypeDate
	LogicalTypeTime
	LogicalTypeMap
	LogicalTypeMapEntry
)

type MapCodec

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

MapCodec is a codec for maps. We treat it as a slice of structs with the key and value as the fields in the structs.

func (*MapCodec) Append

func (c *MapCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (*MapCodec) Descriptor

func (c *MapCodec) Descriptor() Descriptor

func (*MapCodec) New

func (c *MapCodec) New() unsafe.Pointer

func (*MapCodec) Omit

func (c *MapCodec) Omit(ptr unsafe.Pointer) bool

func (*MapCodec) Read

func (c *MapCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (*MapCodec) Size

func (c *MapCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (*MapCodec) WireType

func (c *MapCodec) WireType() plenccore.WireType

type Outputter

type Outputter interface {
	StartObject()
	EndObject()
	StartArray()
	EndArray()
	NameField(name string)

	Int64(v int64)
	Uint64(v uint64)
	Float64(v float64)
	Float32(v float32)
	String(v string)
	Bool(v bool)
	Time(t time.Time)
	Raw(v string)
}

Outputter is an interface that a Descriptor uses to turn plenc data to some other output

type PointerWrapper

type PointerWrapper struct {
	Underlying Codec
}

PointerWrapper wraps a codec so it can be used for a pointer to the type

func (PointerWrapper) Append

func (p PointerWrapper) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (PointerWrapper) Descriptor

func (p PointerWrapper) Descriptor() Descriptor

func (PointerWrapper) New

func (p PointerWrapper) New() unsafe.Pointer

func (PointerWrapper) Omit

func (p PointerWrapper) Omit(ptr unsafe.Pointer) bool

func (PointerWrapper) Read

func (p PointerWrapper) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (PointerWrapper) Size

func (p PointerWrapper) Size(ptr unsafe.Pointer, tag []byte) int

func (PointerWrapper) WireType

func (p PointerWrapper) WireType() plenccore.WireType

type ProtoMapCodec added in v0.0.12

type ProtoMapCodec struct {
	*MapCodec
}

func (ProtoMapCodec) Append added in v0.0.12

func (c ProtoMapCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (ProtoMapCodec) Read added in v0.0.12

func (c ProtoMapCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (ProtoMapCodec) Size added in v0.0.12

func (c ProtoMapCodec) Size(ptr unsafe.Pointer, tag []byte) (size int)

func (ProtoMapCodec) WireType added in v0.0.12

func (c ProtoMapCodec) WireType() plenccore.WireType

type ProtoSliceWrapper added in v0.0.11

type ProtoSliceWrapper struct {
	BaseSliceWrapper
}

ProtoSliceWrapper is for encoding slices of WTLength encoded objects how protobuf does it. When writing the elements of the slice are simply repeated. When reading each element is treated separately and appended to the slice.

Note this does not work outside of a struct as we don't add tags and therefore the length of each element is not known

func (ProtoSliceWrapper) Append added in v0.0.11

func (c ProtoSliceWrapper) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

Append appends the data for this slice, including repeated tags and lengths for each element

func (ProtoSliceWrapper) Read added in v0.0.11

func (c ProtoSliceWrapper) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (ProtoSliceWrapper) Size added in v0.0.11

func (c ProtoSliceWrapper) Size(ptr unsafe.Pointer, tag []byte) int

Size calculates the amount of data needed for this slice, including repeated tags and lengths

type StringCodec

type StringCodec struct{}

StringCodec is a codec for an string

func (StringCodec) Append

func (c StringCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (StringCodec) Descriptor

func (StringCodec) Descriptor() Descriptor

func (StringCodec) New

func (StringCodec) New() unsafe.Pointer

New creates a pointer to a new string header

func (StringCodec) Omit

func (StringCodec) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (StringCodec) Read

func (StringCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a string

func (StringCodec) Size

func (c StringCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (StringCodec) WireType

func (StringCodec) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

func (StringCodec) WithInterning

func (c StringCodec) WithInterning() Codec

type StructCodec

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

func (*StructCodec) Append

func (c *StructCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (*StructCodec) Descriptor

func (c *StructCodec) Descriptor() Descriptor

func (*StructCodec) New

func (c *StructCodec) New() unsafe.Pointer

func (*StructCodec) Omit

func (c *StructCodec) Omit(ptr unsafe.Pointer) bool

func (*StructCodec) Read

func (c *StructCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

func (*StructCodec) Size

func (c *StructCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (*StructCodec) WireType

func (c *StructCodec) WireType() plenccore.WireType

type TimeCodec

type TimeCodec struct{}

TimeCodec is a codec for Time Note that this is not compatible with google.protobuf.Timestamp. The structure is the same, but they don't use zigzag encoding for the fields. They still do allow negative values though

func (TimeCodec) Append

func (c TimeCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (TimeCodec) Descriptor

func (tc TimeCodec) Descriptor() Descriptor

func (TimeCodec) New

func (TimeCodec) New() unsafe.Pointer

func (TimeCodec) Omit

func (TimeCodec) Omit(ptr unsafe.Pointer) bool

func (TimeCodec) Read

func (tc TimeCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a Time

func (TimeCodec) Size

func (c TimeCodec) Size(ptr unsafe.Pointer, tag []byte) int

func (TimeCodec) WireType

func (tc TimeCodec) WireType() plenccore.WireType

type TimeCompatCodec added in v0.0.10

type TimeCompatCodec struct {
	TimeCodec
}

func (TimeCompatCodec) Append added in v0.0.10

func (c TimeCompatCodec) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (TimeCompatCodec) Read added in v0.0.10

func (tc TimeCompatCodec) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a Time

func (TimeCompatCodec) Size added in v0.0.10

func (c TimeCompatCodec) Size(ptr unsafe.Pointer, tag []byte) int

type UintCodec

type UintCodec[T uint | uint8 | uint16 | uint32 | uint64] struct{}

UintCodec is a coddec for a uint

func (UintCodec[T]) Append

func (c UintCodec[T]) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (UintCodec[T]) Descriptor

func (c UintCodec[T]) Descriptor() Descriptor

func (UintCodec[T]) New

func (c UintCodec[T]) New() unsafe.Pointer

New creates a pointer to a new Int

func (UintCodec[T]) Omit

func (c UintCodec[T]) Omit(ptr unsafe.Pointer) bool

Omit indicates whether this field should be omitted

func (UintCodec[T]) Read

func (UintCodec[T]) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a Int

func (UintCodec[T]) Size

func (c UintCodec[T]) Size(ptr unsafe.Pointer, tag []byte) int

func (UintCodec[T]) WireType

func (c UintCodec[T]) WireType() plenccore.WireType

WireType returns the wire type used to encode this type

type WTFixedSliceWrapper

type WTFixedSliceWrapper struct {
	BaseSliceWrapper
}

WTFixedSliceWrapper is a codec for a type that's encoded as a fixed 32 or 64 byte value (i.e. float32 or float64)

func (WTFixedSliceWrapper) Append

func (p WTFixedSliceWrapper) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (WTFixedSliceWrapper) Read

func (c WTFixedSliceWrapper) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a slice. It assumes the WTLength tag has already been decoded and that the data slice is the corect size for the slice

func (WTFixedSliceWrapper) Size

func (p WTFixedSliceWrapper) Size(ptr unsafe.Pointer, tag []byte) int

type WTLengthSliceWrapper

type WTLengthSliceWrapper struct {
	BaseSliceWrapper
}

WTLengthSliceWrapper is a codec for a slice of a type that's encoded using the WTLength wire type. It uses the WTSlice wire type for the slice itself.

func (WTLengthSliceWrapper) Append

func (c WTLengthSliceWrapper) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (WTLengthSliceWrapper) Read

func (c WTLengthSliceWrapper) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a slice. It assumes the WTLength tag has already been decoded and that the data slice is the corect size for the slice

func (WTLengthSliceWrapper) Size

func (c WTLengthSliceWrapper) Size(ptr unsafe.Pointer, tag []byte) int

func (WTLengthSliceWrapper) WireType

type WTVarIntSliceWrapper

type WTVarIntSliceWrapper struct {
	BaseSliceWrapper
}

WTVarIntSliceWrapper is a codec for a type encoded using the WTVarInt wire type.

func (WTVarIntSliceWrapper) Append

func (p WTVarIntSliceWrapper) Append(data []byte, ptr unsafe.Pointer, tag []byte) []byte

func (WTVarIntSliceWrapper) Read

func (c WTVarIntSliceWrapper) Read(data []byte, ptr unsafe.Pointer, wt plenccore.WireType) (n int, err error)

Read decodes a slice. It assumes the WTLength tag has already been decoded and that the data slice is the correct size for the slice

func (WTVarIntSliceWrapper) Size

func (p WTVarIntSliceWrapper) Size(ptr unsafe.Pointer, tag []byte) int

Jump to

Keyboard shortcuts

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