19 releases

0.7.33 Feb 19, 2022
0.7.26 Dec 8, 2021
0.7.20 Oct 23, 2021
0.7.4 Jul 22, 2021
0.2.0 Nov 19, 2020

#1805 in Procedural macros

Download history 34/week @ 2022-10-07 24/week @ 2022-10-14 15/week @ 2022-10-21 24/week @ 2022-10-28 35/week @ 2022-11-04 34/week @ 2022-11-11 31/week @ 2022-11-18 17/week @ 2022-11-25 28/week @ 2022-12-02 32/week @ 2022-12-09 70/week @ 2022-12-16 40/week @ 2022-12-23 50/week @ 2022-12-30 46/week @ 2023-01-06 29/week @ 2023-01-13 25/week @ 2023-01-20

157 downloads per month
Used in 2 crates (via rkyv_typename)

MIT license

115 lines


rkyv (archive) is a zero-copy deserialization framework for Rust

Discord docs.rs crates.io MIT license


Learning Materials

  • The rkyv book covers the motivation, architecture, and major features of rkyv
  • The rkyv discord is a great place to get help with specific issues and meet other people using rkyv



  • The rust serialization benchmark is a shootout style benchmark comparing many rust serialization solutions. It includes special benchmarks for zero-copy serialization solutions like rkyv.

Sister Crates

  • bytecheck, which rkyv uses for validation
  • ptr_meta, which rkyv uses for pointer manipulation
  • rend, which rkyv uses for endian-agnostic features


use rkyv::{Archive, Deserialize, Serialize};
// bytecheck can be used to validate your data if you want
use bytecheck::CheckBytes;

#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
// This will generate a PartialEq impl between our unarchived and archived types
// To use the safe API, you have to derive CheckBytes for the archived type
#[archive_attr(derive(CheckBytes, Debug))]
struct Test {
    int: u8,
    string: String,
    option: Option<Vec<i32>>,

let value = Test {
    int: 42,
    string: "hello world".to_string(),
    option: Some(vec![1, 2, 3, 4]),

// Serializing is as easy as a single function call
let bytes = rkyv::to_bytes::<_, 256>(&value).unwrap();

// Or you can customize your serialization for better performance
// and compatibility with #![no_std] environments
use rkyv::ser::{Serializer, serializers::AllocSerializer};

let mut serializer = AllocSerializer::<0>::default();
let bytes = serializer.into_serializer().into_inner();

// You can use the safe API for fast zero-copy deserialization
let archived = rkyv::check_archived_root::<Test>(&bytes[..]).unwrap();
assert_eq!(archived, &value);

// Or you can use the unsafe API for maximum performance
let archived = unsafe { rkyv::archived_root::<Test>(&bytes[..]) };
assert_eq!(archived, &value);

// And you can always deserialize back to the original type
let deserialized: Test = archived.deserialize(&mut rkyv::Infallible).unwrap();
assert_eq!(deserialized, value);

Note: the safe API requires the validation feature:

rkyv = { version = "0.7", features = ["validation"] }

Read more about available features.


Thanks to all the sponsors that keep development sustainable. Special thanks to the following sponsors for going above and beyond supporting rkyv:

Platinum Sponsors

Dusk Network

Dusk Network is the first privacy blockchain for financial applications. Our mission is to enable any size enterprise to collaborate at scale, meet compliance requirements, and ensure that transaction data remains confidential.

Bronze Sponsors

Traverse Research


~14K SLoC