Versionize is a framework for version tolerant serializion/deserialization of Rust data structures, designed for usecases that need fast deserialization times and minimal size overhead. It does not aim to be a generic serialization framework and only the bincode backend is supported.
Important note
This crate is currently used for cross-version serialization with the Firecracker snapshot-restore dev preview, but has not been tested for other use cases. It should be considered experimental software outside the Firecracker context. It’s likely that this crate will see both interface and implementation changes in the future.
Versionize in action
extern crate versionize;
extern crate versionize_derive;
use ;
use Versionize;
// The test structure is at version 3.
// Memory to hold the serialization output.
let mut mem = vec!;
// Create a new version map - it will start at app version 1.
let mut version_map = new;
// Map structure versions to app version.
version_map
.new_version // App version 2.
.set_type_version // Struct(2) -> App(2).
.new_version // App version 3.
.set_type_version; // Struct(3) -> App(3).
let test_struct = Test ;
// Serialize to app version 2 - field c will not be serialized.
test_struct
.serialize
.unwrap;
// Deserialize from app version 2 - c should contain the default_fn() return value.
let restored_test_struct = deserialize.unwrap;
assert_eq!;