varint

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBufTooSmall = errors.New("varint: buf too small")

ErrBufTooSmall is returned when there is not enough data for parsing a varint.

Functions

func EncodedSize added in v0.12.0

func EncodedSize(n uint64) (size int)

EncodedSize returns the size required to varint-encode an uint.

func GetNextBlock

func GetNextBlock(data []byte) ([]byte, int, error)

GetNextBlock extract the integer from the beginning of the given byte slice and returns the remaining bytes, the extracted integer, and whether there was an error.

func Pack16

func Pack16(n uint16) []byte

Pack16 packs a uint16 into a VarInt.

func Pack32

func Pack32(n uint32) []byte

Pack32 packs a uint32 into a VarInt.

func Pack64

func Pack64(n uint64) []byte

Pack64 packs a uint64 into a VarInt.

func Pack8

func Pack8(n uint8) []byte

Pack8 packs a uint8 into a VarInt.

func PrependLength

func PrependLength(data []byte) []byte

PrependLength prepends the varint encoded length of the byte slice to itself.

func Unpack16

func Unpack16(blob []byte) (uint16, int, error)

Unpack16 unpacks a VarInt into a uint16. It returns the extracted int, how many bytes were used and an error.

func Unpack32

func Unpack32(blob []byte) (uint32, int, error)

Unpack32 unpacks a VarInt into a uint32. It returns the extracted int, how many bytes were used and an error.

func Unpack64

func Unpack64(blob []byte) (uint64, int, error)

Unpack64 unpacks a VarInt into a uint64. It returns the extracted int, how many bytes were used and an error.

func Unpack8

func Unpack8(blob []byte) (uint8, int, error)

Unpack8 unpacks a VarInt into a uint8. It returns the extracted int, how many bytes were used and an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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