rkyv
A zero-copy deserialization framework for Rust
Repository Health
Technical Analysis
rkyv (“archive”) is a zero-copy deserialization framework for Rust. Instead of parsing bytes into fresh in-memory structures, rkyv lays out data so that a serialized buffer can be accessed directly as typed values with no decoding step, making reads effectively free and dramatically faster than traditional serializers for read-heavy workloads.
rkyv works by deriving Archive, Serialize, and Deserialize implementations for your types, producing an “archived” representation you can read in place, optionally validate for safety, and fully deserialize when you need owned values. It supports no_std and no-alloc targets, endian-agnostic layouts, and a rich set of built-in type implementations, and is one of the fastest serialization solutions in the Rust ecosystem.
What You Get
- Derive macros (Archive, Serialize, Deserialize) that generate zero-copy archived types
- Direct in-place access to serialized data with no allocation or decode step
- Optional bytecheck validation for safely reading untrusted or mmap’d buffers
- no_std and no-alloc support for embedded and constrained targets
- Built-in archived implementations for standard collections, strings, options, and more
Common Use Cases
- Loading large data files or memory-mapped assets with near-instant access
- High-throughput, read-heavy pipelines where deserialization is the bottleneck
- Embedded and no_std systems that cannot afford allocation-heavy parsing
- Persisting and reloading complex Rust data structures with minimal overhead
Under The Hood
Architecture — rkyv is built around three derivable traits (Archive, Serialize, Deserialize) whose codegen lives in the rkyv_derive crate. The core rkyv crate organizes the pipeline into ser/ (serializers and writers), de/ (deserializers), validation/ (bytecheck-based buffer checking), and per-type impls/ plus first-class modules for strings, vecs, collections, boxed/rc pointers, options, and tuples. rel_ptr.rs and place.rs implement the relative-pointer and in-place construction machinery that make zero-copy layouts possible, while niche/ and simd/ provide space and speed optimizations. The workspace also includes rkyv_dyn for trait-object support.
Tech Stack — Pure Rust with heavy use of const generics and unsafe for layout control, targeting stable Rust with no_std and no-alloc support (categories encoding/no-std). It leans on sister crates from the same org: rend for endian-agnostic primitives, bytecheck for validation, rancor for error handling, ptr_meta and munge for pointer/field manipulation. Optional Cargo features gate integrations with arrayvec, bytes, hashbrown, and others.
Code Quality — The crate is extensively modularized by type and concern, ships a dedicated validation layer, and is accompanied by the rkyv book, a SECURITY.md, and a benchlib plus an external serialization-benchmark shootout where it consistently ranks at the top for zero-copy workloads. Millions of downloads and a large dependent ecosystem exercise it in production.
API Design — The everyday API is remarkably terse — derive the three traits, call rkyv::to_bytes, then access or deserialize the archive — as shown in the README’s complete example. The #[rkyv(…)] attribute customizes generated types and comparisons. The conceptual model (archived vs owned types, relative pointers, validation) has a real learning curve, which the rkyv book and Discord exist to smooth over.
Used by 2 apps in this directory
iii
Developer Tools · Devops
Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.