{"id":20339130,"url":"https://github.com/firecracker-microvm/versionize","last_synced_at":"2025-04-05T04:13:18.894Z","repository":{"id":42018561,"uuid":"259237858","full_name":"firecracker-microvm/versionize","owner":"firecracker-microvm","description":"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. ","archived":false,"fork":false,"pushed_at":"2024-01-02T15:14:27.000Z","size":96,"stargazers_count":53,"open_issues_count":11,"forks_count":32,"subscribers_count":24,"default_branch":"main","last_synced_at":"2024-04-24T15:43:06.433Z","etag":null,"topics":["serialization"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firecracker-microvm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY-POLICY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-27T07:25:08.000Z","updated_at":"2024-06-19T11:30:24.834Z","dependencies_parsed_at":"2023-10-15T03:33:00.467Z","dependency_job_id":"ef3f774e-a2e0-4f3c-a39d-a2272bf75009","html_url":"https://github.com/firecracker-microvm/versionize","commit_stats":{"total_commits":58,"total_committers":13,"mean_commits":4.461538461538462,"dds":0.6724137931034483,"last_synced_commit":"97d83ee205064b6dc75f1a7e03b4bbe4d05e8488"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firecracker-microvm","download_url":"https://codeload.github.com/firecracker-microvm/versionize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284951,"owners_count":20913704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["serialization"],"created_at":"2024-11-14T21:15:30.168Z","updated_at":"2025-04-05T04:13:18.867Z","avatar_url":"https://github.com/firecracker-microvm.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Versionize is a framework for version tolerant serializion/deserialization of\nRust data structures, designed for usecases that need fast deserialization \ntimes and minimal size overhead. It does not aim to be a generic serialization \nframework and only the [bincode](https://crates.io/crates/bincode) backend is \nsupported.**\n\n## Important note\n\nThis crate is currently used for cross-version serialization with the \n[Firecracker snapshot-restore dev preview][1], but has not been tested for \nother use cases. It should be considered **experimental software** outside the \nFirecracker context. It’s likely that this crate will see both interface and \nimplementation changes in the future.\n\n## Versionize in action\n\n```rust\nextern crate versionize;\nextern crate versionize_derive;\n\nuse versionize::{VersionMap, Versionize, VersionizeResult};\nuse versionize_derive::Versionize;\n\n// The test structure is at version 3.\n#[derive(Debug, PartialEq, Versionize)]\npub struct Test {\n    a: u32,\n    #[version(start = 2, end = 3)]\n    b: u8,\n    #[version(start = 3, default_fn = \"default_c\")]\n    c: String,\n}\n\nimpl Test {\n    // Default value for field `c`.\n    // The callback is invoked when deserializing an older version\n    // where the field did not exist.\n    fn default_c(_source_version: u16) -\u003e String {\n        \"test_string\".to_owned()\n    }\n}\n\n// Memory to hold the serialization output.\nlet mut mem = vec![0u8; 512];\n// Create a new version map - it will start at app version 1.\nlet mut version_map = VersionMap::new();\n// Map structure versions to app version.\nversion_map\n    .new_version() // App version 2.\n    .set_type_version(Test::type_id(), 2) // Struct(2) -\u003e App(2).\n    .new_version() // App version 3.\n    .set_type_version(Test::type_id(), 3); // Struct(3) -\u003e App(3).\n\nlet test_struct = Test {\n    a: 1337,\n    b: 0xFF,\n    c: \"c_value\".to_owned(),\n};\n\n// Serialize to app version 2 - field c will not be serialized.\ntest_struct\n    .serialize(\u0026mut mem.as_mut_slice(), \u0026version_map, 2)\n    .unwrap();\n\n// Deserialize from app version 2 - c should contain the default_fn() return value.\nlet restored_test_struct = Test::deserialize(\u0026mut mem.as_slice(), \u0026version_map, 2).unwrap();\n\nassert_eq!(\n    restored_test_struct,\n    Test {\n        a: 1337,\n        b: 255,\n        c: \"test_string\".to_owned()\n    }\n);\n```\n\n[1]: https://github.com/firecracker-microvm/firecracker/tree/v0.24.0","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirecracker-microvm%2Fversionize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirecracker-microvm%2Fversionize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirecracker-microvm%2Fversionize/lists"}