varint

package
v0.0.0-...-f076e03 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBackward

func AppendBackward[T constraints.Integer](dst []byte, value T) []byte

AppendBackward appends an integer value to a byte slice using a variable length encoding, which can be read back in a backward parsing manner.

This encoding is identical to AppendForward, except that bytes are emitted in reverse order.

func AppendForward

func AppendForward[T constraints.Integer](dst []byte, value T) []byte

AppendForward appends an integer value to a byte slice using a variable length encoding, which can be read back in a forward parsing manner.

The encoding used by this function is similar to UTF-8, except that it is simplified to no longer be self-synchronizing. The number of leading 0-bits corresponds to the number of trailing bytes. Trailing bytes do not have any special prefix. Values are sign extended.

func ConsumeBackward

func ConsumeBackward[T constraints.Integer](src []byte) (T, int)

ConsumeBackward consumes an integer value from the head of a byte slice, which was encoded using AppendBackward().

func ConsumeForward

func ConsumeForward[T constraints.Integer](src []byte) (T, int)

ConsumeForward consumes an integer value from the head of a byte slice, which was encoded using AppendForward().

func ReadForward

func ReadForward[T constraints.Integer](r io.ByteReader) (T, error)

func SizeBytes

func SizeBytes[T constraints.Integer](value T) int

SizeBytes returns the size of the variable length encoded integer generated by AppendBackward() or AppendForward().

Types

This section is empty.

Jump to

Keyboard shortcuts

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