varint

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVarIntTooBig = errors.New("mcproto: var int is too big")
)

Functions

func DecodeReaderVarInt

func DecodeReaderVarInt(reader io.Reader) (result int32, numRead int, err error)

DecodeReaderVarInt takes an io.Reader as a parameter and returns in order:

- the result varint

- the number of bytes read

- an eventual error

NOTE: It returns the number of bytes read even in occurance of an error

func DecodeReaderVarLong added in v0.1.1

func DecodeReaderVarLong(reader io.Reader) (result int64, numRead int, err error)

DecodeReaderVarInt takes an io.Reader as a parameter and returns in order:

- the result varlong

- the number of bytes read

- an eventual error

NOTE: It returns the number of bytes read even in occurance of an error

func EncodeVarInt

func EncodeVarInt(inputValue int32) (varint []byte, n int)

EncoeVarInt is an implementation of the varint encoding as specified on wiki.vg

It takes an int32 as an input, and returns the encoded varint in the form of a byte slice, and also returns n which is the number of bytes the varint takes

func EncodeVarLong added in v0.1.1

func EncodeVarLong(inputValue int64) (varint []byte, n int)

EncoeVarLong is an implementation of the varlong encoding as specified on wiki.vg

It takes an int64 as an input, and returns the encoded varint in the form of a byte slice, and also returns n which is the number of bytes the varint takes

Types

This section is empty.

Jump to

Keyboard shortcuts

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