Library / SDK
rkyv/rkyv avatar
rkyv/rkyv

rkyv and the cost of reading archived data in place

Zero-copy deserialization framework for Rust

4,406 stars243 forksRustMIT

At a glance

What is it?
rkyv turns Rust values into fixed-layout written forms you can read without deserializing, and the price is a validation step plus a compatibility contract you cannot escape. It suits engineers storing long-lived Rust-shaped bytes, not teams that need a loose schema.
Who is it for?
Adopt rkyv when your bytes are written and read by the same Rust program, the fixed layout is fixed at compile time, and the buffer is long-lived enough to amortize the bytecheck traversal. Do not adopt it when a non-Rust consumer has to read the data, when the shape must change without a migration, or when you need to log the payload as ordinary text.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 58 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 21, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • rkyv/rkyv4,406 ★ · +45
Star history
Repository2026-09-232026-11-21
rkyv/rkyv4.4k4.4k

45 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The generated type sits next to your own, not in place of it

rkyv does not need to deserialize into your struct to read it. It generates a second type, the generated form, whose fields are fixed layout and byte aligned, and it reads those bytes where they lie. Your original Test stays a Rust value; ArchivedTest is what lands in the buffer. The derive macro is where this split happens, and it takes arguments rather than leaving everything automatic.

rust
#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
#[rkyv(
    compare(PartialEq),
    derive(Debug),
)]
struct Test {
    int: u8,
    string: String,
    option: Option<Vec<i32>>,
}

That compare attribute is worth pausing on. Without it, no PartialEq exists between your type and the generated one, which means the ergonomic way to assert a round trip is gone. Derives can also be passed straight through to the generated type. The design assumes you will test against the stored bytes rather than against a rebuilt value, and it makes you opt in.

Validation happens through bytecheck before any field is read

Reading untrusted bytes with zero-copy is a memory safety question, not a speed question. rkyv answers it by refusing to hand you a reference until the buffer has been checked. bytecheck is the crate that walks the stored structure and verifies the data is in range, and it is enabled by default because the safe API depends on it.

The README states it in one line: the safe API requires the bytecheck feature. Turn that feature off and the checked accessors are simply not offered to you. So the access path is gated on validation by construction. This is the single most important thing to understand before choosing rkyv, because a skipped check is not a slower read, it is an unchecked read of bytes that may not be the bytes you think they are.

The cost is one full traversal of the buffer. For a store-forward format loaded once and queried many times, that is a fair trade. For a small message decoded on every request, you have added work to save work.

Feature flags decide what the stored layout can contain

The README sends readers to the crate's docs page for the list of available features.

Pinning the feature set in one place in your manifest keeps every build on the same configuration.

The workspace manifest sits ahead of the version on crates.io

The root Cargo.toml declares version = "0.8.18" for the workspace and pins rkyv_derive to =0.8.18, while the newest GitHub release listed is 0.8.8.

This is the detail a skim misses. Reading source on the repository and depending on the published crate are two different builds, and a detail you confirm in the source is not guaranteed in the binary your service ships. Read the manifest version before you read anything else, then decide whether you are testing the tree or the crate.

The same file sets the toolchain floor: rust-version = "1.81" with edition 2021. That line is the oldest compiler your users can build with, and it is stricter than many Cargo manifests state out loud.

Trait objects live in a separate crate that the workspace has switched off

The README points at rkyv_dyn as the crate that adds trait object support, and the repository contains rkyv_dyn, rkyv_dyn_derive and rkyv_dyn_test directories. All three are commented out in the workspace members list, and default-members is only rkyv and rkyv_derive.

Read that as a build configuration statement: a plain cargo build of this repository never compiles the trait object code, so it never gets tested by the default build. If your design needs to archive trait objects, you are depending on a part of the project that the workspace itself has stepped back from, and your feedback will come from your own integration rather than from the core test run.

The same split shows in the dependency list. bytecheck, ptr_meta, rancor and rend are declared at version 0.8, 0.3, 0.1 and 0.5, and each is also redirected to a git source under patch.crates-io. Within this repository you are building those crates from their git repositories rather than from published releases.

Reading from bytes requires the safe accessors, not a cast

Once a buffer is checked, the stored value is reachable through typed accessors rather than a raw pointer dereference, which is what lets the crate return references into the original buffer instead of copies. The example in the README builds a Test with a u8, a String and an Option<Vec<i32>>, and serializes it.

The functions named in the example's import line are deserialize, Archive, Deserialize and Serialize, with errors coming from rancor::Error. That error type is the point where the sister crates stop being an implementation detail: rancor owns error handling, rend supplies endian-agnostic primitives, ptr_meta handles pointer metadata, and bytecheck does validation. Any of the four changing behaviour changes rkyv's contract with your code.

Where bincode differs: owned output versus borrowed lifetime

bincode is the obvious comparison, and the difference is structural rather than a matter of speed. bincode encodes values into a stream and decodes them by constructing new owned values, so the result is a normal Rust type you can keep, mutate and drop whenever you like. There is no validation step because there is nothing to trust after a successful decode.

rkyv inverts that. It writes a fixed-layout image, then hands back borrows tied to that image, and it will not do so until bytecheck says the bytes are consistent. You get cheap repeated access and near-zero construction cost, at the cost of a lifetime attached to the buffer and a validation traversal you cannot skip if you want the safe API.

Choose bincode when the decoded value escapes the request, changes, or crosses a language boundary. Choose rkyv when the buffer is long-lived and read repeatedly, and you control every writer.

Editorial conclusion

Adopt rkyv when your bytes are written and read by the same Rust program, the fixed layout is fixed at compile time, and the buffer is long-lived enough to amortize the bytecheck traversal. Do not adopt it when a non-Rust consumer has to read the data, when the shape must change without a migration, or when you need to log the payload as ordinary text. Remember that trait objects come from rkyv_dyn, which the workspace does not build. Verify first, before writing any feature code, that a buffer saved to disk and reloaded can be read back through the safe API in a test.

Frequently asked questions

What does rkyv do that serde does not?

rkyv writes archived forms with fixed layout and alignment and reads them in place, returning references into the original buffer instead of constructing owned values. serde based formats rebuild the values instead, which costs allocation but yields an ordinary Rust struct.

Do I have to enable the bytecheck feature to use rkyv safely?

The README states that the safe API requires the bytecheck feature, which is enabled by default. Without it the checked accessors that guard against invalid archived data are not available.

Is rkyv still being developed?

The repository is not archived and its last push was on 2026-09-25. Tag history tells a flatter story: 0.8.8, 0.8.7 and 0.8.6 all landed on 2024-09-18.

Can rkyv archive trait objects?

Support comes from the separate rkyv_dyn crate rather than the core library. Its directories are present in the repository but commented out of the workspace members list, so the default build does not compile them.

What Rust version does rkyv require?

The workspace manifest sets rust-version = "1.81" and edition 2021. Anything older than that compiler will not build the crate.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. rkyv/rkyv on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rkyv-rkyv.svg)](https://hysenlabs.com/projects/rkyv-rkyv)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/rkyv-rkyv.svg)](https://hysenlabs.com/projects/rkyv-rkyv)

Was this useful?