MCPcopy Index your code
hub / github.com/dermesser/integer-encoding-rs

github.com/dermesser/integer-encoding-rs @v4.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.1.0 ↗ · + Follow
77 symbols 140 edges 10 files 8 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

integer-encoding-rs

GitHub repo crates.io version crate usage docs.rs status crates.io license CI 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.

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.

Crate

If you use Tokio v0.2 and you use the asynchronous types in this crate (feature tokio_async), you may be interested in the v2.0 branch. It is still maintained with the occasional fix for edge cases and depends on Tokio v0.2.

FixedInt

FixedInt casts integers to bytes by either copying the underlying memory or performing a transmutation. The encoded values use are little-endian.

However, a trait method is implemented for all integer types allowing convenient conversion between little and big endian. That is, if you receive a big-endian on the wire and decode it, it will first be interpreted as little-endian; converting will recover the correct value.

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.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 47
Method 18
Interface 11
Class 1

Languages

Rust100%

Modules by API surface

src/varint_tests.rs17 symbols
src/fixed_tests.rs16 symbols
src/reader.rs13 symbols
src/varint.rs11 symbols
src/writer.rs8 symbols
examples/read_write_file.rs4 symbols
benches/main.rs4 symbols
src/fixed.rs2 symbols
examples/encode_varint_from_stdin.rs2 symbols

For agents

$ claude mcp add integer-encoding-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page