Inflate
A pure Rust implementation of DEFLATE and zlib decompression
Repository Health
Technical Analysis
Inflate is a pure Rust library that decompresses data encoded with the DEFLATE algorithm, both with and without a zlib header and trailer. It has no C dependencies and provides simple helper functions to turn compressed bytes back into a decoded byte vector.
The crate exposes several levels of control: one-shot helpers like inflate_bytes and inflate_bytes_zlib, a std::io::Write-based InflateWriter for streaming decompression, and lower-level building blocks for advanced use. Long a foundational dependency for image and archive tooling in the Rust ecosystem, it is distributed under the permissive MIT license.
What You Get
- One-shot decompression via
inflate_bytesandinflate_bytes_zlib - A streaming
InflateWriterimplementingstd::io::Write - Support for both raw DEFLATE and zlib-wrapped input
- A dependency-light, pure-Rust implementation with no C bindings
Common Use Cases
- Decompressing DEFLATE streams inside image decoders such as PNG
- Reading zlib-compressed payloads from files or network protocols
- Building archive or format parsers that need raw inflate support
- Decoding compressed data in constrained or portable Rust builds
Under The Hood
Architecture - Inflate implements the DEFLATE decoder as a state machine over a bit reader, exposing three tiers: convenience functions (inflate_bytes, inflate_bytes_zlib), an InflateWriter adapter that implements std::io::Write and buffers into an inner writer, and lower-level primitives for custom decoding loops.
Tech Stack - Written entirely in Rust with the adler32 crate for zlib checksum verification and no C dependencies, distributed as the inflate crate on crates.io.
Code Quality - A small, focused codebase with example-driven documentation in the README; it is mature and battle-tested through wide downstream use, though development has been largely inactive since 2019.
API Design - The API is minimal and approachable: a single function call handles the common case, while the writer and lower-level APIs offer progressively more control for streaming and advanced scenarios.