{"id":13995338,"url":"https://github.com/devashishdxt/desse","last_synced_at":"2025-04-07T17:11:00.789Z","repository":{"id":34436771,"uuid":"177744729","full_name":"devashishdxt/desse","owner":"devashishdxt","description":"Ultra fast binary serialization and deserialization for types with a constant size (known at compile time).","archived":false,"fork":false,"pushed_at":"2023-05-23T21:57:58.000Z","size":111,"stargazers_count":106,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T14:15:18.408Z","etag":null,"topics":["binary","no-std","rust","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/devashishdxt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-26T08:25:37.000Z","updated_at":"2025-01-17T07:57:22.000Z","dependencies_parsed_at":"2024-01-20T18:04:01.699Z","dependency_job_id":"c9aa092d-13f9-4399-a568-09e8f4ba22cd","html_url":"https://github.com/devashishdxt/desse","commit_stats":{"total_commits":84,"total_committers":5,"mean_commits":16.8,"dds":"0.23809523809523814","last_synced_commit":"e698d736a17050c53af847e910b39f251f76f5ac"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Fdesse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Fdesse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Fdesse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Fdesse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devashishdxt","download_url":"https://codeload.github.com/devashishdxt/desse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694876,"owners_count":20980733,"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":["binary","no-std","rust","serialization"],"created_at":"2024-08-09T14:03:21.376Z","updated_at":"2025-04-07T17:11:00.762Z","avatar_url":"https://github.com/devashishdxt.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Desse [![Build Status](https://travis-ci.org/devashishdxt/desse.svg?branch=master)](https://travis-ci.org/devashishdxt/desse)\nUltra fast binary serialization and deserialization for types with a constant size (known at compile time). This\ncrate cannot be used to serialize or deserialize dynamically allocated types, such as,\n[`String`](std::string::String), [`Vec`](std::vec::Vec), [`HashMap`](std::collections::HashMap), etc., and types \nwith unknown size at compile time such as `slices`, `\u0026str`, etc.\n\n## Binary Encoding Scheme\nThis crate uses a minimal binary encoding scheme such that the size of encoded object will be smaller than (in cases\nwhere Rust adds padding bytes for alignment) or equal to it's size in a running Rust program. For example, consider\nthe following `struct`:\n\n```\nstruct MyStruct {\n    a: u8,\n    b: u16,\n}\n```\n\n`DesseStatic::serialize` will serialize this struct in `[u8; 3]` where `3` is the sum of sizes of `u8` and `u16`.\n\n## Usage\nAdd `desse` in your `Cargo.toml`'s `dependencies` section.\n```\n[dependencies]\ndesse = \"0.2\"\n```\n\n`DesseStatic` trait can be implemented for any struct or enum (whose size is known at compile time) using `derive`\nmacro. This crate also provides a `derive` macro for implementing `DesseSized` trait which is necessary for implementing\n`DesseStatic` trait.\n```\nuse desse::{DesseStatic, DesseSized};\n\n#[derive(Debug, PartialEq, DesseStatic, DesseSized)]\nstruct MyStruct {\n    a: u8,\n    b: u16,\n}\n```\n\nNow, you can use `DesseStatic::serialize` and `DesseStatic::deserialize_from` for serialization and deserialization of\nthis struct.\n\n```\nlet my_struct = MyStruct { a: 5, b: 1005 };\nlet serialized: [u8; 3] = my_struct.serialize();\nlet new_struct = MyStruct::deserialize_from(\u0026serialized);\n\nassert_eq!(my_struct, new_struct);\n```\n\nNote that `DesseStatic::serialize` returns an array of fixed length (`3` in above case) and `Desse::deserialize` takes\nreference to an array of fixed length as argument.\n\n## Performance\nThis crate values performance more than anything. We don't shy away from using tested and verified **unsafe** code\nif it improves performance.\n\n### Benchmarks\nBelow are the benchmark results of comparison between `desse` and `bincode` serializing and deserializing same `struct`:\n```\nstruct::serialize/desse::serialize\n                        time:   [1.6228 ns 1.6326 ns 1.6434 ns]\n                        change: [-1.1985% +0.0554% +1.2769%] (p = 0.94 \u003e 0.05)\n                        No change in performance detected.\nFound 8 outliers among 100 measurements (8.00%)\n  2 (2.00%) high mild\n  6 (6.00%) high severe\n\nstruct::serialize/bincode::serialize\n                        time:   [19.991 ns 20.081 ns 20.201 ns]\n                        change: [-1.0739% +0.3569% +1.7361%] (p = 0.63 \u003e 0.05)\n                        No change in performance detected.\nFound 12 outliers among 100 measurements (12.00%)\n  3 (3.00%) high mild\n  9 (9.00%) high severe\n\nstruct::deserialize/desse::deserialize\n                        time:   [1.6063 ns 1.6101 ns 1.6144 ns]\n                        change: [-1.3079% -0.1278% +1.0394%] (p = 0.84 \u003e 0.05)\n                        No change in performance detected.\nFound 7 outliers among 100 measurements (7.00%)\n  1 (1.00%) high mild\n  6 (6.00%) high severe\n\nstruct::deserialize/bincode::deserialize\n                        time:   [22.004 ns 22.094 ns 22.209 ns]\n                        change: [-1.1573% +0.0698% +1.3631%] (p = 0.92 \u003e 0.05)\n                        No change in performance detected.\nFound 9 outliers among 100 measurements (9.00%)\n  3 (3.00%) high mild\n  6 (6.00%) high severe\n```\n\nIt is clear from above benchmarks that `bincode` takes `20.081 ns` on an average for serialization whereas `desse` takes\n`1.6326 ns`. The results are also similar for deserialization where `bincode` takes `22.094 ns` and `desse` takes\n`1.6101 ns`.\n\nYou can run benchmarks by running following command:\n```\ncargo bench\n```\n\n## Future Improvements\nOnce [`const_generics`](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md) is implemented\nin Rust, we can provide default implementations for many types such as, `impl DesseStatic for [T; n] where T: DesseStatic`,\nand other variable size statically allocated types in Rust.\n\n## License\nLicensed under either of\n- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license (http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as \ndefined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevashishdxt%2Fdesse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevashishdxt%2Fdesse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevashishdxt%2Fdesse/lists"}