{"id":20339129,"url":"https://github.com/firecracker-microvm/versionize_derive","last_synced_at":"2025-05-11T09:59:12.396Z","repository":{"id":49415560,"uuid":"259238816","full_name":"firecracker-microvm/versionize_derive","owner":"firecracker-microvm","description":"Exports the Versionize derive proc macro that generates the Versionize implementation for structs, enums and unions by using structure annotations.","archived":false,"fork":false,"pushed_at":"2023-08-24T10:40:31.000Z","size":35,"stargazers_count":12,"open_issues_count":5,"forks_count":21,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-11T09:59:04.726Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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:29:18.000Z","updated_at":"2025-03-18T04:16:24.000Z","dependencies_parsed_at":"2024-06-21T15:34:10.598Z","dependency_job_id":"7d06159e-fd51-4a41-b4a8-d290b2a3827f","html_url":"https://github.com/firecracker-microvm/versionize_derive","commit_stats":{"total_commits":33,"total_committers":10,"mean_commits":3.3,"dds":0.6666666666666667,"last_synced_commit":"0e4d616f3449313b1af4dc52ece63025c6fff20c"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize_derive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize_derive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize_derive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firecracker-microvm%2Fversionize_derive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firecracker-microvm","download_url":"https://codeload.github.com/firecracker-microvm/versionize_derive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253547214,"owners_count":21925544,"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":[],"created_at":"2024-11-14T21:15:30.157Z","updated_at":"2025-05-11T09:59:12.374Z","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#### You may be looking for:\n- [Versionize documentation](https://docs.rs/versionize/)\n- [Releases](https://github.com/firecracker-microvm/versionize_derive/releases)\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\n    extern crate versionize;\n    extern crate versionize_derive;\n\n    use versionize::{VersionMap, Versionize, VersionizeResult};\n    use versionize_derive::Versionize;\n\n    // The test structure is at version 3.\n    #[derive(Debug, PartialEq, Versionize)]\n    pub 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\n    impl Test {\n        // Default value for field `c`.\n        // The callback is invoked when deserialization from and 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.\n    let mut mem = vec![0u8; 512];\n    // Create a new version map - it will start at version 1.\n    let mut version_map = VersionMap::new();\n    // Add new version and mark changes for Test struct: Set the current version\n    // to point to Test struct version 2.\n    version_map\n        .new_version()\n        .set_type_version(Test::type_id(), 2)\n        .new_version()\n        .set_type_version(Test::type_id(), 3);\n\n    let test_struct = Test {\n        a: 1337,\n        b: 0xFF,\n        c: \"c_value\".to_owned(),\n    };\n\n    // Serialize to version 2 - field c will not be serialized.\n    test_struct\n        .serialize(\u0026mut mem.as_mut_slice(), \u0026version_map, 2)\n        .unwrap();\n\n    // Deserialize from version 2 - c should contain the default_fn() return value.\n    let restored_test_struct = Test::deserialize(\u0026mut mem.as_slice(), \u0026version_map, 2).unwrap();\n\n    assert_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_derive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirecracker-microvm%2Fversionize_derive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirecracker-microvm%2Fversionize_derive/lists"}