#deserialize #field #serialization #binary #backward #de #compatible

no-std binver

Binary (de)serialization framework that is backwards compatible with versioned fields

2 releases

0.1.1 Jun 20, 2021
0.1.0 Jun 20, 2021

#31 in #backward

MIT/Apache

17KB
295 lines

Crates.io Build status docs.io codecov

binver

Binary (de)serialization framework that is backwards compatible with versioned fields.


#[derive(Serializable, PartialEq, Debug)]
pub struct Player {
    // This field has existed since binary version 0.0.1
    #[since(0.0.1)]
    pub id: u32,

    // In 0.0.2 we introduced a new field
    // When loading a serialized 0.0.1 object, this field will have it's `Default` value
    #[since(0.0.2)]
    pub name: String,
}

let player = Player {
    id: 5,
    name: String::from("foo")
};

let serialized = binver::to_vec(&player);
let deserialized_player = binver::deserialize_slice(&serialized).unwrap();

assert_eq!(player, deserialized_player);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5MB
~38K SLoC