vint64

package module
v0.0.0-...-c9a1021 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

README

vint64

Variable length integer encoding per https://docs.rs/vint64/latest/vint64/

Documentation

Overview

Package vint64 implements the vint64 variable length integer encoding

Index

Constants

View Source
const MaxLen = 9

MaxLen is the maximum number of bytes required to encode an integer.

Variables

View Source
var ErrLeadingZeros = errors.New("vint: encoded integer contains leading zeros")

ErrLeadingZeros is returned by Decode when the encoded integer contains unnecessary leading zeros.

Functions

func Append

func Append(b []byte, v uint64) []byte

Append appends the encoding of v to b and returns the resulting slice.

To encode a signed integer, convert the input with Zigzag.

func Decode

func Decode(b []byte) (v uint64, err error)

Decode parses an integer from b.

The number of bytes read can be determined with DecodedLen.

To decode a signed integer, convert the result with Unzigzag.

func DecodedLen

func DecodedLen(b byte) int

DecodedLen returns the number of bytes in the encoded integer.

The result will always be in [0, 9].

func Encode

func Encode(b *[MaxLen]byte, v uint64) int

Encode writes v to b, returning the number of bytes written.

To encode a signed integer, convert the input with Zigzag.

func EncodedLen

func EncodedLen(v uint64) int

EncodedLen returns the number of bytes necessary to encode v.

The result will always be in [0, 9].

func Read

func Read(r io.ByteReader) (uint64, error)

Read parses an integer from b.

To decode a signed integer, convert the result with Unzigzag.

func Unzigzag

func Unzigzag(v uint64) int64

Unzigzag decodes the unsigned integer as a signed integer.

func Zigzag

func Zigzag(v int64) uint64

Zigzag encodes a signed integer as an unsigned integer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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