rkyv

Rust 的零拷贝反序列化框架。「Zero-copy deserialization framework for Rust」

Github stars Tracking Chart

Resources

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

Documentation

Benchmarks

  • 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

Example

use rkyv::{
    archived_root,
    ser::{serializers::AllocSerializer, Serializer},
    Archive, Deserialize, Infallible, Serialize,
};
#[derive(Archive, Deserialize, Serialize, Debug, PartialEq)]
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]),
};
let mut serializer = AllocSerializer::<256>::default();
serializer.serialize_value(&value).unwrap();
let bytes = serializer.into_serializer().into_inner();
let archived = unsafe { archived_root::<Test>(&bytes[..]) };
assert_eq!(archived.int, value.int);
assert_eq!(archived.string, value.string);
assert_eq!(archived.option, value.option);
let deserialized: Test = archived.deserialize(&mut Infallible).unwrap()
assert_eq!(deserialized, value);

Thanks

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

Main metrics

Overview
Name With Ownerrkyv/rkyv
Primary LanguageRust
Program languageRust (Language Count: 1)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2020-11-05 07:11:05
Pushed At2025-04-17 12:50:10
Last Commit At
Release Count76
Last Release Name0.8.8 (Posted on )
First Release Namev0.1.1 (Posted on )
用户参与
Stargazers Count3.2k
Watchers Count20
Fork Count184
Commits Count1k
Has Issues Enabled
Issues Count438
Issue Open Count48
Pull Requests Count139
Pull Requests Open Count1
Pull Requests Close Count28
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private