bincode

A compact, zero-fluff binary encoder and decoder for turning Rust structs into space-efficient byte streams.

Library
Cargo
v3.0.0
3,062stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
37/100Needs Attention
Development Activity0
Maintenance0
Community48
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture80
Code Quality78
Innovation74
Learning Curve70

Bincode is a Rust crate for encoding and decoding data using a tiny binary serialization strategy. It converts an in-memory object into a Vec<u8> (or writes it directly to any Writer) using an encoding that is the same size as, or smaller than, the value’s in-memory representation, with no field names or type metadata stored in the output.

Version 2 rebuilt the crate around its own Encode/Decode traits with an optional derive macro, making serde an opt-in dependency rather than a hard requirement, and it works in no_std environments via the alloc feature. It ships a configurable Configuration type for choosing endianness, fixed vs. variable-length integer encoding, and size limits, and is used in projects such as tarpc, WebRender, ipc-channel, and zoxide for RPC payloads, record/replay tooling, and on-disk storage.

What You Get

  • encode_to_vec / decode_from_slice for in-memory buffers, plus encode_into_std_write / decode_from_std_read for files and sockets and encode_into_slice for pre-allocated or embedded targets
  • Encode, Decode, and BorrowDecode derive macros (via the derive feature) so structs and enums opt in without hand-written impls
  • A Configuration builder for choosing little/big endian byte order, fixed vs. variable-length integer encoding, and an optional size limit to guard against untrusted input
  • Optional serde integration (bincode::serde module) for encoding/decoding types that only implement serde’s Serialize/Deserialize
  • no_std support via the alloc feature, with atomics, HashMap/HashSet (behind std), and common alloc container support (Vec, String, Box, etc.)

Common Use Cases

  • Serializing RPC request/response payloads between Rust services, as used by Google’s tarpc
  • Persisting application state or caches to disk in a compact format, as used by zoxide’s directory-frequency database
  • Sending structs between processes over an IPC channel, as used by servo/ipc-channel
  • Recording and replaying structured event streams for debugging or testing, as used by WebRender

Under The Hood

Architecture: The crate is organized around two trait families, Encode/Decode (plus BorrowDecode for zero-copy borrowing), each driven through a shared Config trait rather than function parameters, so encoding/decoding behavior (endianness, integer width, size limits) is fixed at the type level via Configuration<E, I, L> marker generics. The public entry points in src/lib.rs (encode_to_vec, encode_into_slice, decode_from_slice, encode_into_std_write, decode_from_std_read, etc.) construct a Writer/Reader implementation (SliceWriter, SizeWriter, IoWriter/IoReader for std) and hand it to an EncoderImpl/DecoderImpl in src/enc and src/de, which walk the value’s Encode/Decode implementation. Primitive and container impls live in src/enc/impls.rs, src/de/impls.rs, and src/features/impl_alloc.rs/impl_std.rs, split so alloc- and std-only types (Vec, HashMap, Mutex, Path) are gated behind their respective Cargo features and stay out of no_std builds. Variable-length integers get a dedicated src/varint module with per-width encode/decode tables, and src/features/serde provides a Compat/BorrowCompat bridge so serde-only types can be encoded without the crate’s own derive macros.

Tech Stack: Pure Rust, #![no_std] at the crate root with alloc/std opted back in via Cargo features (default = ["std", "derive"]). The only mandatory runtime dependency is unty (a small type-equality helper); bincode_derive (the proc-macro crate, a sibling in the same Cargo workspace) and serde are both optional, feature-gated dependencies. Dev-dependencies for testing and benchmarking include criterion (benchmarks in benches/varint.rs, benches/inline.rs, benches/string.rs), serde_json, rand, uuid, chrono, glam, ouroboros, and even the older bincode 1.x crate (aliased bincode_1) to test cross-version wire compatibility. MSRV is pinned to Rust 1.85.0 targeting the 2021 edition.

Code Quality: Test coverage is substantial for a serialization crate — 24 files under tests/ covering basic types, derive-generated impls, derive field renaming, serde interop, atomics, allocation-heavy containers, error-size regressions, and a dedicated tests/issues/ directory for regression tests tied to specific bug reports. Error handling is explicit and non-exhaustive: EncodeError and DecodeError in src/error.rs are #[non_exhaustive] enums with named variants (UnexpectedEnd, RefCellAlreadyBorrowed, Io { inner, index }, LockFailed, etc.) rather than a single opaque error type, so callers can match on failure causes. Public items are documented under #![warn(missing_docs, unused_lifetimes)], and the crate carries a docs/spec.md file formally describing the wire format plus a docs/migration_guide.md for bincode-1-to-2 upgrades — an unusually thorough documentation surface for a low-level encoding crate.

API Design: The public API is small and consistent — a handful of encode_*/decode_* free functions distinguished by their input/output medium (slice, Vec, std::io reader/writer, or a generic Reader/Writer), paired with a fluent Configuration builder (config::standard().with_big_endian().with_variable_int_encoding()) instead of a long list of function arguments. The derive feature (on by default) lets most structs and enums opt in with #[derive(Encode, Decode)] and no boilerplate; the crate-level doc comment even ships a runnable example showing derive, encode, and decode in under fifteen lines, plus a compatibility table mapping situations (file/socket vs. in-memory buffer vs. embedded) to the right function pair.

Used by 17 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

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
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
Rust
95%
MIT

Fyrox

Game Development

9,512

A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts

View details
85
Repo Health
79
Technical
68
Dependency
Built with
Rust95%
Updated yesterday
Rust
91%
Apache 2.0

herdr

AI Agents · Developer Tools

30,468

A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.

View details
83
Repo Health
84
Technical
76
Dependency
Built with
Rust91%
Updated today
JavaScript
57%
Other

Lokus

Note Taking · Knowledge Management

774

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
78
Repo Health
75
Technical
65
Dependency
Built with
JavaScript57%
HTML24%
Updated 1 weeks ago
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 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

Search