Skip to main content

Crate compress_lib

Crate compress_lib 

Source
Expand description

§compress_lib

DEFLATE (RFC 1951), zlib (RFC 1950), and gzip (RFC 1952) for Rust services, with the per-message rules of WebSocket permessage-deflate (RFC 7692).

The engine is sans-IO: the caller pushes input and pulls output through buffers it owns. Memory is fixed when an engine is built and never grows with input, and every decoder enforces an absolute output cap while it decodes, so a decompression bomb costs at most the cap. There is no unsafe code and no third-party runtime dependency.

§Tier 1

Add it with Cargo’s rename, compress = { package = "compress-lib", version = "0.2" }, and code reads compress::. In 0.2 the checksums are ready:

use compress_lib::checksum::{adler32, crc32};

assert_eq!(crc32(b"123456789"), 0xCBF4_3926);
assert_eq!(adler32(b"Wikipedia"), 0x11E6_0398);

Decoders take Limits (64 MiB of output by default) and encoders a Level (0 to 9, zlib’s meaning). Every failure is an Error with a matchable ErrorKind and a stable code for logs and metrics.

§Status

0.2.0, the design lock: the complete planned API, each item with the version it arrives in, is docs/API.md in the repository. The checksums, the error type, the limits, and the levels ship now; the raw DEFLATE inflater arrives in 0.3, the deflater and the RFC 7692 helpers in 0.4, zlib and gzip in 0.5.

Modules§

checksum
CRC-32 and Adler-32.

Structs§

Error
A codec error: its ErrorKind and the input offset where it was found.
Level
A compression level, 0 to 9, with zlib’s meaning: 0 stores without compressing, 1 is the fastest, 9 compresses best, 6 is the default.
Limits
Caps a decoder enforces while it decodes.

Enums§

ErrorKind
What went wrong, as a stable, matchable value.

Constants§

VERSION
Crate version string, populated by Cargo at build time.