Module varint

Source
Expand description

Variable-length integer encoding and decoding

This module implements Google’s Protocol Buffers variable-length integer encoding. Each byte uses 7 bits for the value and 1 bit to indicate if more bytes follow.

Functions§

read
Decodes a unsigned 64-bit integer from a varint
read_i64
Decodes a signed 64-bit integer from a varint using ZigZag encoding
size
Calculates the number of bytes needed to encode a value as a varint
size_i64
Calculates the number of bytes needed to encode a signed integer as a varint
write
Encodes a unsigned 64-bit integer as a varint
write_i64
Encodes a signed 64-bit integer as a varint using ZigZag encoding