10 releases (5 breaking)

0.5.1 Apr 7, 2021
0.4.0 Feb 19, 2021
0.2.1 Dec 12, 2020
0.2.0 Nov 19, 2020

#454 in Procedural macros

Download history 7/week @ 2020-12-31 5/week @ 2021-01-07 29/week @ 2021-01-14 9/week @ 2021-01-21 17/week @ 2021-01-28 8/week @ 2021-02-04 29/week @ 2021-02-11 34/week @ 2021-02-18 7/week @ 2021-02-25 5/week @ 2021-03-04 1/week @ 2021-03-11 2/week @ 2021-03-18 34/week @ 2021-03-25 39/week @ 2021-04-01 23/week @ 2021-04-08 21/week @ 2021-04-15

69 downloads per month
Used in rkyv_dyn

MIT license

19KB
341 lines

rkyv   Latest Version License requires: rustc 1.47+

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


API Documentation

Book

  • The rkyv book covers the motivation and architecture of rkyv

Sister Crates:


rkyv in action

use rkyv::{Aligned, Archive, ArchiveBuffer, Archived, archived_value, Write};

#[derive(Archive)]
struct Test {
    int: u8,
    string: String,
    option: Option<Vec<i32>>,
}

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

    let mut writer = ArchiveBuffer::new(Aligned([0u8; 256]));
    let pos = writer.archive(&value).expect("failed to archive test");
    let buf = writer.into_inner();

    let archived = unsafe { archived_value::<Test>(buf.as_ref(), pos) };
    assert_eq!(archived.int, value.int);
    assert_eq!(archived.string, value.string);
    assert_eq!(archived.option, value.option);
}

Dependencies

~350–780KB
~19K SLoC