flate2

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
73 /100 Good
Development Activity 76
Maintenance 60
Community 68
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
87 /100 Excellent
Architecture 88
Code Quality 85
Innovation 90
Learning Curve 85

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 35 apps in this directory

TypeScript
54%
MIT

Anarlog

AI Assistants · Note Taking · Productivity

9,404

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
TypeScript 54%
Rust 34%
Updated 4 days ago
TypeScript
80%
GPL 3.0

Bramble

Authentication · Password Manager · Security

399

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
68
Dependency
Built with
TypeScript 80%
Updated 5 days ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

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
Rust 54%
TypeScript 42%
Updated 4 days ago
Rust
95%
MIT

claw-code

AI Agents · AI Code Assistants

195,291

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
51
Repo Health
71
Technical
77
Dependency
Built with
Rust 95%
Updated 1 months 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
49
Repo Health
68
Technical
68
Dependency
Built with
TypeScript 88%
Updated 4 months ago
Rust
88%
GPL 2.0

Fresh

Code Editors · Developer Tools

9,052

A zero-configuration terminal text editor with familiar keybindings, full mouse support, LSP-powered IDE features, and a built-in orchestrator for running multiple coding agents in parallel worktrees.

View details
86
Repo Health
88
Technical
71
Dependency
Built with
Rust 88%
Updated 5 days ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

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
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
Rust
89%
Apache 2.0

Graphite

Code Editors · Design Tools

27,377

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
70
Dependency
Built with
Rust 89%
Updated 5 days ago
Rust
59%
MIT

Handy

Productivity · Voice AI

32,320

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

View details
87
Repo Health
78
Technical
72
Dependency
Built with
Rust 59%
TypeScript 30%
Updated 4 days ago

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