Serializationv3.2.0

bincode-next

High-performance binary serialization for Rust

MIT OR Apache-2.0Rustno_std · x86_64 · AArch64
3.2.0
Current release
stable toolchain
no_std
Supported
core only
64-bit
Schema fingerprint
format + configuration
2
Wire formats
bincode · CBOR

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 does

SIMD 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 notes
01

Configuration 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.

02

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.

03

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.

04

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.

05

Compatibility surface

The 3.x wire format matches bincode 2.x under identical configuration, and config::legacy() reads the 1.x layout for migration.

06

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
From the crate documentation and docs/spec.md. “Feature” entries are Cargo features; “config” entries are Configuration methods.
CapabilityEnabled byWhat it buys
Zero-copy borrowfeature: zero-copydecode &str, &[u8] and nested structs without allocating
Bit packingconfig: with_bit_packing()sub-byte fields, with PACKED_MAX_SIZE as the bound
Static boundfeature: static-sizeworst-case encoded size known at compile time
Fingerprintconfig: with_fingerprint()64-bit schema hash covering format and configuration
CBORconfig: with_cbor_format()RFC 8949 encoding with deterministic modes
Asyncfeature: async-fiberzero-cost async decoding via UFA
Serde bridgefeature: serdeEncode/Decode for types that derive serde traits

Install

cargo
toml — Cargo.toml
[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.