flate2

Streaming DEFLATE, gzip, and zlib compression for Rust with pluggable backends

Library
Cargo
v1.1.10
1,122stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity88
Maintenance64
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture88
Code Quality85
Innovation90
Learning Curve85

flate2 is the de facto compression library for Rust, providing encoders and decoders for the DEFLATE, zlib, and gzip formats behind familiar Read, BufRead, and Write stream adapters. It wraps low-level compression engines in ergonomic types like GzEncoder, ZlibDecoder, and DeflateEncoder, so you can compress or decompress data by simply wrapping an existing stream.

Under the hood, flate2 supports multiple interchangeable backends selected via Cargo features: the pure-Rust miniz_oxide (default, no C compiler required), the high-performance zlib-rs rewrite, and the system zlib or zlib-ng C libraries. This lets projects trade off portability, performance, and bit-for-bit compatibility without changing their application code.

What You Get

  • Encoder and decoder types for DEFLATE, zlib, and gzip in read, bufread, and write variants
  • A pure-Rust default backend (miniz_oxide) that needs no C compiler and uses only safe Rust
  • Optional high-performance backends: zlib-rs, system zlib, and zlib-ng, selectable via Cargo features
  • Low-level Compress/Decompress in-memory stream primitives for maximum control
  • A GzBuilder for constructing gzip streams with custom headers and metadata

Common Use Cases

  • Transparently gzip-compressing or decompressing HTTP request and response bodies
  • Reading and writing .gz files without shelling out to external tools
  • Compressing data before storing it in a database, cache, or on disk
  • Decoding zlib- or DEFLATE-compressed payloads inside binary file formats and protocols

Under The Hood

Architecture flate2 is organized around three format modules — deflate, zlib, and gz — each mirroring the same read.rs/bufread.rs/write.rs layout so every format offers Read, BufRead, and Write adapters with an identical shape (src/deflate, src/zlib, src/gz). These stream types delegate to the raw Compress/Decompress primitives in src/mem.rs, which in turn drive a pluggable backend selected in src/ffi through the Backend, DeflateBackend, and InflateBackend traits. The src/ffi directory holds one implementation per backend (miniz_oxide.rs, zlib_rs.rs, c.rs), so the format and I/O layers stay backend-agnostic while mem.rs and zio.rs handle buffering and the compress/flush/finish state machine.

Tech Stack Written in pure Rust (edition 2018, rust-version 1.67), flate2 depends on miniz_oxide for the default safe-Rust backend, crc32fast for checksums, and optional libz-sys, libz-ng-sys, and zlib-rs crates for alternate backends, all gated behind additive Cargo features. Backend selection is resolved entirely at compile time, and document-features is used to generate the feature-flag documentation.

Code Quality The crate is mature and well tested: integration tests cover capabilities, early flushing, empty reads, zero-length writes, and gzip decoding (tests/), and a fuzz/ harness plus quickcheck property tests exercise edge cases. Public types carry extensive rustdoc with runnable examples, and the 27 files under examples/ demonstrate every encoder/decoder variant. The layered design keeps unsafe confined to the C and zlib-rs FFI backends, with the default path staying entirely in safe Rust.

API Design The public API is highly idiomatic: encoders and decoders implement std::io::Read/Write, so they compose with the rest of the Rust I/O ecosystem with zero glue code — you wrap a stream, read or write bytes, and call finish(). Naming is consistent and predictable (GzEncoder, ZlibDecoder, DeflateEncoder) across all three format modules, and getting started requires only a couple of lines. The Compression level type and GzBuilder provide finer control when needed without complicating the common case.

Used by 32 apps in this directory

TypeScript
53%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,252

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
68
Dependency
Built with
TypeScript53%
Rust35%
Updated today
TypeScript
79%
GPL 3.0

Bramble

Password Manager · Security · Authentication

381

Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.

View details
75
Repo Health
84
Technical
72
Dependency
Built with
TypeScript79%
Updated 3 days ago
Rust
53%
Other

Cap

Team Chat · Video Conferencing

21,859

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust53%
TypeScript43%
Updated yesterday
Rust
95%
MIT

claw-code

AI Agents · AI Code Assistants

195,189

A Rust-built CLI agent harness for Claude AI with persistent sessions, MCP tool integration, plugin hooks, and multi-provider support — designed to run autonomous coding workflows without human babysitting.

View details
57
Repo Health
71
Technical
77
Dependency
Built with
Rust95%
Updated 3 weeks ago
TypeScript
88%
MIT

DevTools-X

Developer Tools

1,534

41 offline-first developer utilities in a single 10MB cross-platform desktop app — no Electron, no cloud, no compromise.

View details
50
Repo Health
68
Technical
68
Dependency
Built with
TypeScript88%
Updated 3 months ago
Rust
67%
Other

GitButler

Developer Tools · Devops · AI Development

21,624

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
67
Dependency
Built with
Rust67%
TypeScript20%
Svelte11%
Updated yesterday
Rust
89%
Apache 2.0

Graphite

Code Editors · Design Tools

27,145

A free, open source procedural 2D design tool that unifies vector, raster, motion graphics, and generative art in a single node-based nondestructive workflow.

View details
84
Repo Health
77
Technical
71
Dependency
Built with
Rust89%
Updated today
Rust
58%
MIT

Handy

Productivity

31,111

Free, offline, open-source speech-to-text that pastes directly into any app on Windows, macOS, and Linux.

View details
86
Repo Health
78
Technical
73
Dependency
Built with
Rust58%
TypeScript30%
Updated 2 days ago
Python
81%
Apache 2.0

headroom

AI Development · Developer Tools

69,144

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
84
Repo Health
86
Technical
72
Dependency
Built with
Python81%
Rust13%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search