#quantity #variant #variable-length #speed #focus #byte #vlq

no-std fastvlq

A fast variant of Variable-Length Quantity with a focus on speed and no_std support

5 releases (3 stable)

1.1.1 Aug 31, 2021
1.0.0 Apr 20, 2021
1.0.0-alpha.2 Oct 11, 2020
1.0.0-alpha.1 Oct 8, 2020

#1034 in Encoding

Download history 25/week @ 2024-07-23 24/week @ 2024-07-30 10/week @ 2024-08-06 6/week @ 2024-08-13 15/week @ 2024-08-20 15/week @ 2024-08-27 33/week @ 2024-09-03 39/week @ 2024-09-10 64/week @ 2024-09-17 58/week @ 2024-09-24 317/week @ 2024-10-01 90/week @ 2024-10-08 89/week @ 2024-10-15 89/week @ 2024-10-22 51/week @ 2024-10-29 977/week @ 2024-11-05

1,228 downloads per month
Used in 15 crates (2 directly)

Apache-2.0 OR MIT

18KB
457 lines

fastvlq

Actions Status Documentation

Encode and decode with a variant of variable-length quantity data.

The algorithm uses leading zeros to count how many bytes are required for decoding.

Usage

Add this to your Cargo.toml:

[dependencies]
fastvlq = "1"

Where is this used?

  • box - a modern replacement for the zip file format

License

Licensed under either of

at your option.


lib.rs:

Algorithm

Fast VLQ is a variant of value-length quantity encoding, with a focus on encoding and decoding speed. The total number of bytes can always be derived from the very first byte, and unlike VLQ, the integer type supported is u64 exclusively, and will take up a maximum of 9 bytes (for values greater than 56-bit).

This crate does not enforce an invariant that a number may only have one representation, which means that it is possible to encode 1 as, for example, both 0b1000_0001 and 0b0100_0000_0000_0001.

Usage

Add this to your Cargo.toml:

[dependencies]
fastvlq = "1"

Dependencies

~235–375KB