compact

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBits

func DecodeBits(data []byte) []*rye.Bits

EncodeBits takes a slice of *Bits and encodes them as a single []byte. The []*Bits can be recovered with DecodeBits. The structure of the encoded data is a CompactUint64 for the data length. Then a byte bit length to use when looking up lengths. Then all the lengths are encoded, then all the Bits are encoded.

func EncodeBits

func EncodeBits(bs []*rye.Bits) []byte

EncodeBits takes a slice of *Bits and encodes them as a single []byte. The []*Bits can be recovered with DecodeBits.

func Int64SignLSB

func Int64SignLSB(x int64) uint64

Int64SignLSB converts an int64 to a uint64 by placing the sign in the least significant bit (as opposted to 2's compliment). For compact encoding, this makes increases the number of leading zeros that can be dropped for compact encoding.

func Size

func Size(data []byte) uint64

Size of the data in compact form

func SizeInt64

func SizeInt64(x int64) uint64

SizeCompactInt64 of x in compact form

func SizeUint

func SizeUint(x uint64) uint64

SizeUint is the number of bytes needed to encode x ignoring leading zero bytes.

func SizeUint64

func SizeUint64(x uint64) uint64

SizeCompactUint64 of x in compact form

Types

type Deserializer

type Deserializer struct {
	*rye.Deserializer
}

func NewDeserializer

func NewDeserializer(data []byte) Deserializer

func (Deserializer) CompactInt64

func (d Deserializer) CompactInt64() int64

CompactInt64 reads an Int64 in compact form.

func (Deserializer) CompactSlice

func (d Deserializer) CompactSlice() []byte

CompactSlice reads a byte slice in compact form.

func (Deserializer) CompactString

func (d Deserializer) CompactString() string

CompactString reads the string as a compact byte slice.

func (Deserializer) CompactSub

func (d Deserializer) CompactSub() Deserializer

CompactSub returns a Sub-Deserializer where the underlying slice is from CompactSlice. The index of the parent is placed at the end of the data allocated to the Sub-Deserializer.

func (Deserializer) CompactUint64

func (d Deserializer) CompactUint64() uint64

CompactUint64 reads a Uint64 in compact form.

type Serializer

type Serializer struct {
	*rye.Serializer
}

func NewSerializer

func NewSerializer(size int) Serializer

func (Serializer) CompactInt64

func (s Serializer) CompactInt64(x int64)

CompactInt64 writes an Int64 in compact form.

func (Serializer) CompactSlice

func (s Serializer) CompactSlice(data []byte)

CompactSlice writes a byte slice in compact form.

func (Serializer) CompactString

func (s Serializer) CompactString(str string)

CompactString writes the string as a compact byte slice.

func (Serializer) CompactUint64

func (s Serializer) CompactUint64(x uint64)

CompactUint64 writes x to the Serializer in the CompactUint64 format.

Jump to

Keyboard shortcuts

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