leb128

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 4 Imported by: 21

README

LEB128

Little Endian Base 128 | Variable-Length Code Compression

Usage

bs, _ := leb128.EncodeUnsigned(big.NewInt(200000))
// [192 154 12]
bi, _ := leb128.DecodeUnsigned(bytes.NewReader(bs))
// 200000

Uses

  • LEB128 is used in the WebAssembly binary encoding for all integer literals.
  • LEB128 is used by Candid to serialise types into a binary representation for transfer between services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSigned

func DecodeSigned(r *bytes.Reader) (*big.Int, error)

DecodeSigned converts the byte slice back to a signed integer.

func DecodeUnsigned

func DecodeUnsigned(r *bytes.Reader) (*big.Int, error)

DecodeUnsigned converts the byte slice back to an unsigned integer.

Types

type LEB128

type LEB128 []byte

LEB128 represents an unsigned number encoded using (unsigned) LEB128.

func EncodeSigned

func EncodeSigned(n *big.Int) (LEB128, error)

EncodeSigned encodes a signed integer.

func EncodeUnsigned

func EncodeUnsigned(n *big.Int) (LEB128, error)

EncodeUnsigned encodes an unsigned integer.

type SLEB128

type SLEB128 []byte

SLEB128 represents a signed number encoded using signed LEB128.

Jump to

Keyboard shortcuts

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