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
- rkyv, the core library
- rkyv_dyn, which adds trait object support to rkyv
- rkyv_typename, a type naming library
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 ;
// Derives can be passed through to the generated type:
let value = Test ;
// Serializing is as easy as a single function call
let bytes = .unwrap;
// Or you can customize your serialization for better performance
// and compatibility with #![no_std] environments
use ;
let mut serializer = default;
serializer.serialize_value.unwrap;
let bytes = serializer.into_serializer.into_inner;
// You can use the safe API for fast zero-copy deserialization
let archived = .unwrap;
assert_eq!;
// Or you can use the unsafe API for maximum performance
let archived = unsafe ;
assert_eq!;
// And you can always deserialize back to the original type
let deserialized: Test = archived.deserialize.unwrap;
assert_eq!;
Note: the safe API requires the validation
feature:
= { = "0.7", = ["validation"] }
Read more about available features.