zstd
Idiomatic Rust bindings for the Zstandard compression library
Repository Health
Technical Analysis
zstd provides safe, idiomatic Rust bindings around Facebook’s Zstandard (zstd) compression library, exposing Read/Write stream wrappers alongside simple one-shot encode/decode helper functions. It builds on the lower-level zstd-safe and zstd-sys crates in the same workspace, compiling the vendored C library as part of the build so consumers get zstd compression without needing a system dependency.
The crate is one of the most widely used compression bindings in the Rust ecosystem, powering compression layers in databases, build tools, and network protocols where zstd’s balance of speed and ratio is preferred over gzip or bzip2.
What You Get
- Streaming
Encoder/Decodertypes implementing standardRead/Writetraits - One-shot helper functions (
encode_all,decode_all,copy_encode,copy_decode) - Dictionary training and dictionary-based compression via the
zdict_builderfeature - Multi-threaded compression support via the
zstdmtfeature - Optional
bindgen-based binding regeneration and apkg-configfeature to link a system zstd
Common Use Cases
- Compressing log files, backups, or build artifacts before storage or transfer
- Adding transparent zstd compression to a custom network protocol or RPC layer
- Compressing/decompressing data streams inside a CLI tool (mirrors the
zstd/zstdcatexamples in the repo) - Training a shared dictionary to improve compression ratio on many small, similar payloads
Under The Hood
Architecture — The repository is a small Cargo workspace: the top-level zstd crate (this package) provides ergonomic Read/Write wrappers (src/stream/) and bulk one-shot helpers (src/bulk/) on top of zstd-safe, a safe-but-thin layer that itself wraps zstd-safe/zstd-sys, the raw FFI bindings generated against the vendored zstd C sources (included as a git submodule). This three-tier layering (raw FFI → safe wrapper → ergonomic API) is a common pattern for Rust bindings to C libraries and keeps unsafe code isolated to the -sys crate.
Tech Stack — Pure Rust wrapper crate targeting edition 2018 with a 1.64 MSRV; it depends only on zstd-safe (path dependency within the workspace) for the runtime API, with clap, humansize, partial-io, and walkdir as dev-dependencies used by the CLI examples and test harness. The C library itself is compiled from source via a build script in zstd-sys.
Code Quality — The crate has a small dedicated tests/ directory plus doctests embedded in the stream/bulk modules, and CI badges show Linux/Windows/macOS/wasm build matrices. Error handling follows the underlying C library’s return-code conventions surfaced as io::Result, which is idiomatic for a Read/Write-based API.
API Design — The crate intentionally mirrors std::io::copy-style ergonomics (copy_encode/copy_decode) alongside lower-level Encoder/Decoder types, so users needing a quick one-liner and users needing fine-grained streaming control both have a natural entry point; feature flags (zstdmt, zdict_builder, experimental) keep the default build lean while exposing advanced functionality opt-in.
Used by 9 apps in this directory
AFFiNE
Productivity · Project Management · Note Taking
Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.
Hoppscotch
Developer Tools
A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.
InfluxDB
Databases · Analytics
Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.
Kuku
Note Taking
A local-first, open-source Markdown knowledge workspace for macOS — plain files, personal wiki and Second Brain workflows, AI-assisted diffs, and encrypted sync, built as an Obsidian alternative.
open-pencil
AI Design Tools · Design Tools
An open-source design editor that reads native Figma files, ships a built-in AI assistant with 100+ design tools, and offers real-time serverless collaboration — all without giving up your files.
OpenShell
AI Agents · Developer Tools
The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
QuestDB
Databases · Analytics
A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.
Spacedrive
File Storage · Collaboration
One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.