17 stable releases

new 2.1.0 Oct 16, 2020
1.2.1 Aug 30, 2020
1.1.5 Mar 17, 2020
1.0.7 Jun 15, 2019
0.12.0 Jun 19, 2016

#37 in Encoding

Download history 6353/week @ 2020-06-30 7261/week @ 2020-07-07 5978/week @ 2020-07-14 5825/week @ 2020-07-21 7011/week @ 2020-07-28 6906/week @ 2020-08-04 9179/week @ 2020-08-11 8166/week @ 2020-08-18 8296/week @ 2020-08-25 6661/week @ 2020-09-01 7715/week @ 2020-09-08 8183/week @ 2020-09-15 8687/week @ 2020-09-22 9559/week @ 2020-09-29 9918/week @ 2020-10-06 7062/week @ 2020-10-13

33,836 downloads per month
Used in 84 crates (22 directly)

Custom license

29KB
640 lines

integer-encoding-rs

crates.io Build Status

full documentation

This crate provides encoding and decoding of integers to and from bytestring representations.

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

FixedInt

FixedInt casts integers to bytes by either copying the underlying memory or performing a transmutation. The encoded values use machine endianness (little-endian on x86).

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.

Dependencies

~0–710KB
~13K SLoC