Scope
Raw DEFLATE inflate and deflate with window bits 8 to 15 and levels 0 to 9; sync, full, and finish flushes; zlib and gzip framing with checksums always verified; preset dictionaries; per-message compression for WebSocket servers and clients (context takeover on or off); CRC-32 and Adler-32; std::io adapters. Brotli follows after 1.0. It does not negotiate HTTP or WebSocket headers (http-net and ws-net do) and it does not read archives.
Quick start
[]
= { = "compress-lib", = "0.4" }
Available now:
let packed = compress; // raw DEFLATE, level 6
let data = decompress?; // capped at 64 MiB
let crc = crc32; // gzip's checksum
WebSocket permessage-deflate (RFC 7692), one direction each:
use ;
let config = new.with_window_bits; // no context takeover by default
let mut tx = new?;
let mut rx = new?;
tx.compress_message?; // sync flush, tail removed
rx.decompress_message?; // budget checked while inflating
Streaming, with buffers you own:
use ;
let p = deflater.compress?; // push input, pull output
let q = inflater.decompress?;
match q.status
Planned for 0.5, the same shape:
let packed = compress; // Vec<u8>, level 6
let body = decompress?; // capped at 64 MiB by default
The complete planned API, with the version each item arrives in, is in docs/API.md.
Contributing
See dev/DIRECTIVES.md for engineering standards and the definition of done. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.