#integer #varint #zigzag

dusk-varint

varint+zigzag integer encoding/decoding (no_std)

1 unstable release

0.1.0 May 26, 2021

#1733 in Encoding

Download history 28/week @ 2023-12-18 19/week @ 2023-12-25 2/week @ 2024-01-01 29/week @ 2024-01-08 22/week @ 2024-01-15 33/week @ 2024-01-22 8/week @ 2024-01-29 26/week @ 2024-02-05 26/week @ 2024-02-12 30/week @ 2024-02-19 50/week @ 2024-02-26 40/week @ 2024-03-04 34/week @ 2024-03-11 36/week @ 2024-03-18 75/week @ 2024-03-25 91/week @ 2024-04-01

246 downloads per month
Used in 16 crates (via canonical)

MIT license

9KB
141 lines

dusk-varint

minimal no_std fork of integer-encoding

The format is described here: Google's protobuf integer encoding technique.

Please feel free to use cargo bench to determine the rate at which your machine can encode and decode varints and fixedints. Note that one iteration comprises each eight rounds of encoding (or decoding) a signed and an unsigned integer each -- divide the resulting benchmark time by 16 in order to have a rough estimate of time per operation. The integers are very large, so the results represent the worst case.

VarInt

VarInt encodes integers in blocks of 7 bits; the MSB is set for every byte but the last, in which it is cleared.

Signed values are first converted to an unsigned representation using zigzag encoding (also described on the page linked above), and then encoded as every other unsigned number.


lib.rs:

Fast serialization of integers.

This crate implements encoding and decoding of integer types to and from VarInt (encoding integers so that they only use as much memory as needed to represent their magnitude).

No runtime deps