rkyv

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

Github星跟踪图

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

概览

名称与所有者rkyv/rkyv
主编程语言Rust
编程语言Rust (语言数: 1)
平台Linux, Mac, Windows
许可证MIT License
发布数66
最新版本名称v0.7.43 (发布于 )
第一版名称v0.1.1 (发布于 )
创建于2020-11-05 07:11:05
推送于2024-05-17 07:19:25
最后一次提交
星数2.6k
关注者数17
派生数155
提交数818
已启用问题?
问题数372
打开的问题数63
拉请求数105
打开的拉请求数2
关闭的拉请求数22
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部