bincode-next
High-performance binary serialization for Rust
Overview
bincode-next is the maintained continuation of bincode: a binary encoder and decoder pair that adds no framing, no field names and no padding. The encoded object is at most the size it occupies in memory, and usually less.
The fork exists for a practical reason — RSSN and the wider ecosystem needed a serialization crate that was still maintained — and it has since grown its own engine: SIMD varint scanning, relative-pointer zero-copy, bit-level packing, schema fingerprinting and an RFC 8949 CBOR front end.
The format is specified rather than implied. A 64-bit schema fingerprint covers field names, types, order and configuration, so a format change (bincode to CBOR, endianness, integer encoding) produces a different fingerprint instead of silently corrupt data.
Capabilities
what it doesSIMD varint scanning
SSE2 on x86_64 and NEON on AArch64 scan varint streams in bulk instead of byte by byte.
Zero-copy structures
Relative pointers and const alignment let nested borrowed data decode in place, with no intermediate allocation.
Bit-level packing
Opt-in bit packing shrinks structs whose fields do not need a whole byte, with a compile-time bound on the worst case.
Schema fingerprinting
A 64-bit hash over field names, types, order and configuration catches format drift before it becomes corrupt data.
Static size bounds
StaticSize and PACKED_MAX_SIZE give worst-case byte counts at compile time, which is what embedded buffers need.
CBOR and async decoding
RFC 8949 CBOR with deterministic modes, plus zero-cost async decoding through the fiber-backed UFA path.
How it works
design notesConfiguration is explicit
There is no implicit default: every encode and decode call takes a Configuration value, so the wire format is a property of the call site rather than of a global.
Varint layout
Integers below 251 occupy one byte; larger values take a marker byte plus a fixed-width integer. The choice between varint and fixint is part of the configuration, and part of the fingerprint.
Zero-copy decoding
A relative pointer stores a byte offset instead of an address, so a decoded structure can borrow directly from the input buffer and remain valid after the buffer moves.
Fingerprint before payload
When enabled, the 64-bit schema hash is written ahead of the payload and checked first, so a mismatched reader fails with a specific error rather than a partial decode.
Compatibility surface
The 3.x wire format matches bincode 2.x under identical configuration, and config::legacy() reads the 1.x layout for migration.
no_std layering
The core is core-only; std adds io::Read/Write streaming, and alloc adds the owned containers. Each layer is a feature, not a separate crate.
Format at a glance
specification| Capability | Enabled by | What it buys |
|---|---|---|
| Zero-copy borrow | feature: zero-copy | decode &str, &[u8] and nested structs without allocating |
| Bit packing | config: with_bit_packing() | sub-byte fields, with PACKED_MAX_SIZE as the bound |
| Static bound | feature: static-size | worst-case encoded size known at compile time |
| Fingerprint | config: with_fingerprint() | 64-bit schema hash covering format and configuration |
| CBOR | config: with_cbor_format() | RFC 8949 encoding with deterministic modes |
| Async | feature: async-fiber | zero-cost async decoding via UFA |
| Serde bridge | feature: serde | Encode/Decode for types that derive serde traits |
Install
cargo[dependencies]
bincode-next = { version = "3.2", features = ["zero-copy"] }The crate is no_std compatible; zero-copy and bit packing are opt-in. Migration notes from 1.x and 2.x are in docs/migration_guide.md.