barrique 2.0.0

Portable binary serialiation format
Documentation

Barrique

License Version

barrique is a schema-based binary serialization format featuring compression, metadata and streaming. The format was designed for locally storing large (>8 MiB) long-term memory objects.

Example

Most likely you'll start with implementations generated by derive macro:

use barrique::region::{AllocOrd, Seed};
use barrique::{Encode, Decode};
use barrique::frame::Frame;

#[derive(Encode, Decode, Clone, Debug, PartialEq)]
struct Bee {
    name: String,
    state: State,
    #[barrique(skip(default_expr = "2"))]
    age: u8,
}

#[derive(Encode, Decode, Clone, Debug, PartialEq)]
#[barrique(tag_repr = "u8")]
enum State {
    Collecting(i32, i32),
    Buzzing {
        sound_level: u8
    },
    Sleeping
}

fn main() {
    let bee = Bee {
        name: "Oh, hey!".to_string(),
        state: State::Sleeping,
        age: 2
    };
    let mut dst = vec![];

    let frame = Frame::new(&mut dst, Seed::new(0))
        .with_label("A beehive".try_into().unwrap());
    frame.encode(bee.clone()).unwrap();

    let frame: Frame<Bee, _> = Frame::decode(dst.as_slice(), Seed::new(0))
        .expect("Failed to open a frame");

    assert_eq!(frame.get_value(AllocOrd::default()).unwrap(), bee);
}

Visit Docs for more information.

Specification

Barrique serialization format specification declared here