{"id":28207970,"url":"https://github.com/flixcoder/serde-brief","last_synced_at":"2025-06-29T01:37:46.262Z","repository":{"id":257804097,"uuid":"857710382","full_name":"FlixCoder/serde-brief","owner":"FlixCoder","description":"A brief, self-descriptive, serde-compatible binary format.","archived":false,"fork":false,"pushed_at":"2025-04-06T15:09:46.000Z","size":76,"stargazers_count":17,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-06T23:17:03.998Z","etag":null,"topics":["binary","no-std","rust","serde"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/serde-brief","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FlixCoder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["FlixCoder"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-09-15T12:03:23.000Z","updated_at":"2025-05-31T10:55:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"741262e6-2515-4313-bfa3-8e994ebc59a0","html_url":"https://github.com/FlixCoder/serde-brief","commit_stats":null,"previous_names":["flixcoder/serde-brief"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/FlixCoder/serde-brief","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlixCoder%2Fserde-brief","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlixCoder%2Fserde-brief/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlixCoder%2Fserde-brief/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlixCoder%2Fserde-brief/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FlixCoder","download_url":"https://codeload.github.com/FlixCoder/serde-brief/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FlixCoder%2Fserde-brief/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259404195,"owners_count":22852138,"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","serde"],"created_at":"2025-05-17T14:11:23.505Z","updated_at":"2025-06-12T05:31:06.034Z","avatar_url":"https://github.com/FlixCoder.png","language":"Rust","funding_links":["https://github.com/sponsors/FlixCoder"],"categories":[],"sub_categories":[],"readme":"# Serde-Brief\n\n[![crates.io page](https://img.shields.io/crates/v/serde-brief.svg)](https://crates.io/crates/serde-brief)\n[![docs.rs page](https://docs.rs/serde-brief/badge.svg)](https://docs.rs/serde-brief/)\n![license: MIT](https://img.shields.io/crates/l/serde-brief.svg)\n\nSerde-Brief (German for letter) is a crate for encoding and decoding data into a binary format that is self-descriptive and [serde](https://docs.rs/serde/)-compatible.\n\n## Design Goals\n\nNot necessarily in order of importance:\n\n- Convenient to use for developers: Integrates into the Rust ecosystem via `serde`, supporting all of its features in its derived implementations (e.g. renaming, flattening, ..).\n- Compatibility: Easy to add or re-order fields/variants without breakage. Detects wrong data types.\n- `#![no_std]` and std compatible.\n- Resource efficient: High performance, low memory usage.\n- Interoperability: Different architectures can communicate flawlessly.\n- Well-tested: Ensure safety (currently, there is no use of `unsafe`).\n\n## Binary Format\n\nThe format is new and therefore NOT YET STABLE.\n\nThe format is specified [here](./docs/format-specification.md).\n\n### Flavors / Modes\n\nBy default, structs' field names and enums' variant names are encoded as strings. This can be configured to be encoded as unsigned integers of their indices instead. However, this has compatibility implications and some serde features do not work with the index representation. See the format specification for more info.\n\n## Comparisons\n\nHow does Serde-Brief compare to ..?\n\n### [Postcard](https://docs.rs/postcard/)\n\nPostcard is NOT a self-describing format. It's encoding solely consists of the raw data and the deserializer needs to have the same information on the data schema. This makes it more difficult to change the data format, e.g. add new fields.\n\nPostcard is producing way smaller encoded data due to the missing schema information and field names. It is also faster.\n\nSerde-Brief supports decoding unknown data and parsing it into the requested structures regardless of additional fields or different orders.\n\n### [Pot](https://docs.rs/pot/)\n\nPot is a self-describing format as well. It's encoding is more space-efficient due to reducing repeated type/schema definitions. This comes at the cost of serialization/deserialization speed.\n\nIt is also not no-std compatible.\n\nSerde-Brief is faster most of the times, but less space-efficient.\n\n### [Serde_json](https://docs.rs/serde_json/)\n\nJSON is a self-describing format as well. However, it is text based and therefore requires string escaping. Bytes cannot be efficiently represented. However, JSON is widely adopted, as you already know :D\n\nIn Serde-Brief, map keys can not only be strings. Unlike in JSON, keys can be nested data, so something like `HashMap\u003cMyKeyStruct, MyValueStruct\u003e` can be serialized and deserialized without issues.\n\nSerde-Brief is both more space-efficient and faster.\n\n## Usage\n\nAdd the library to your project with `cargo add serde-brief`. By default, no features are enabled (currently), so it is no-std by default. You can enable use of `Vec`s and such with features like `alloc` or `std`.\n\n### Example Serialization/Deserialization\n\nThe `heapless` feature was enabled for this example. It is similarly possible with `std`'s `Vec` or just slices.\n\n```rust\nuse heapless::Vec;\nuse serde::{Serialize, Deserialize};\n\n#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]\nstruct MyBorrowedData\u003c'a\u003e {\n    name: \u0026'a str,\n    age: u8,\n}\n\nlet data = MyBorrowedData { name: \"Holla\", age: 21 };\nlet mut output: Vec\u003cu8, 22\u003e = serde_brief::to_heapless_vec(\u0026data).unwrap();\n\nassert_eq!(output, [\n    17,\n    11, 4, b'n', b'a', b'm', b'e', 11, 5, b'H', b'o', b'l', b'l', b'a',\n    11, 3, b'a', b'g', b'e', 3, 21,\n    18\n]);\n\nlet parsed: MyBorrowedData = serde_brief::from_slice(\u0026output).unwrap();\nassert_eq!(parsed, data);\n```\n\n## Benchmarks\n\nFor benchmark results, [see here](https://github.com/djkoloski/rust_serialization_benchmark).\n\nI expect there to be plenty room for performance improvements still.\n\nIf you are interested in maximum performance, please try using profile-guided optimization. It measurably improves performance on this library. For further information, see the [PGO usage docs](./docs/pgo.md).\n\n### Results\n\nThe serialization/deserialization is reasonably fast. Between postcard and serde_json mostly. The data-size is also between postcard and JSON.\n\nI expect there is a lot improvements possible, we are still way slower than postcard sadly.\n\n## Development \u0026 Testing\n\n1. Install [cargo-make](https://github.com/sagiegurari/cargo-make) (and optionally [cargo-nextest](https://github.com/nextest-rs/nextest)): `cargo install cargo-make cargo-nextest`.\n2. Optional, but recommended: Put `search_project_root = true` into cargo-make's user configuration, so that `cargo make` can be run from sub-folders.\n3. From the project directory, you can run the following tasks:\n    - **Format code**: `cargo make format`\n    - **Check formatting**: `cargo make formatting`\n    - **Run all tests via cargo test**: `cargo make test`\n    - **Run all tests via cargo nextest**: `cargo make nextest`\n    - **Run clippy for all feature sets, failing on any warnings**: `cargo make clippy`\n    - **Do all checks that are done in CI**: `cargo make ci`\n\n## Minimum supported Rust version\n\nCurrently, I am always using the latest stable Rust version and do not put in effort to keep the MSRV. Please open an issue in case you need a different policy, I might consider changing the policy.\n\n## License\n\nLicensed under the MIT license. All contributors agree to license under this license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflixcoder%2Fserde-brief","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflixcoder%2Fserde-brief","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflixcoder%2Fserde-brief/lists"}