{"id":13578529,"url":"https://github.com/jamesmunns/postcard","last_synced_at":"2025-12-27T20:23:54.632Z","repository":{"id":37432563,"uuid":"179385478","full_name":"jamesmunns/postcard","owner":"jamesmunns","description":"A no_std + serde compatible message library for Rust","archived":false,"fork":false,"pushed_at":"2025-04-15T13:32:59.000Z","size":513,"stargazers_count":1083,"open_issues_count":69,"forks_count":102,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-06T11:12:05.954Z","etag":null,"topics":[],"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/jamesmunns.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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}},"created_at":"2019-04-03T23:26:26.000Z","updated_at":"2025-05-06T01:04:16.000Z","dependencies_parsed_at":"2024-01-14T03:30:28.730Z","dependency_job_id":"64e4a60e-eac6-401d-8fd0-13c604ac9a31","html_url":"https://github.com/jamesmunns/postcard","commit_stats":{"total_commits":231,"total_committers":51,"mean_commits":4.529411764705882,"dds":0.6753246753246753,"last_synced_commit":"f1c89db8c5c48a3959b22e464fd22829f3c3dd9e"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesmunns%2Fpostcard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesmunns%2Fpostcard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesmunns%2Fpostcard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesmunns%2Fpostcard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesmunns","download_url":"https://codeload.github.com/jamesmunns/postcard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253850294,"owners_count":21973661,"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-08-01T15:01:31.513Z","updated_at":"2025-12-27T20:23:54.582Z","avatar_url":"https://github.com/jamesmunns.png","language":"Rust","readme":"# Postcard\n\n[![Documentation](https://docs.rs/postcard/badge.svg)](https://docs.rs/postcard)\n\n\u003cimg align=\"right\" src=\"assets/logo-512.png\" alt=\"the postcard logo\" width=256px\u003e\n\nPostcard is a `#![no_std]` focused serializer and deserializer for Serde.\n\nPostcard aims to be convenient for developers in constrained environments, while\nallowing for flexibility to customize behavior as needed.\n\n## Design Goals\n\n1. Design primarily for `#![no_std]` usage, in embedded or other constrained contexts\n2. Support a maximal set of `serde` features, so `postcard` can be used as a drop in replacement\n3. Avoid special differences in code between communication code written for a microcontroller or a desktop/server PC\n4. Be resource efficient - memory usage, code size, developer time, and CPU time; in that order\n5. Allow library users to customize the serialization and deserialization  behavior to fit their bespoke needs\n\n## Format Stability\n\nAs of v1.0.0, `postcard` has a documented and stable wire format. More information about this\nwire format can be found in the `spec/` folder of the Postcard repository, or viewed online\nat \u003chttps://postcard.jamesmunns.com\u003e.\n\nWork towards the Postcard Specification and portions of the Postcard 1.0 Release\nwere sponsored by Mozilla Corporation.\n\n## Variable Length Data\n\nAll signed and unsigned integers larger than eight bits are encoded using a [Varint].\nThis includes the length of array slices, as well as the discriminant of `enums`.\n\nFor more information, see the [Varint] chapter of the wire specification.\n\n[Varint]: https://postcard.jamesmunns.com/wire-format.html#varint-encoded-integers\n\n## Example - Serialization/Deserialization\n\nPostcard can serialize and deserialize messages similar to other `serde` formats.\n\nUsing the default `heapless` feature to serialize to a `heapless::Vec\u003cu8\u003e`:\n\n```rust\nuse core::ops::Deref;\nuse serde::{Serialize, Deserialize};\nuse postcard::{from_bytes, to_vec};\nuse heapless::Vec;\n\n#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]\nstruct RefStruct\u003c'a\u003e {\n    bytes: \u0026'a [u8],\n    str_s: \u0026'a str,\n}\nlet message = \"hElLo\";\nlet bytes = [0x01, 0x10, 0x02, 0x20];\nlet output: Vec\u003cu8, 11\u003e = to_vec(\u0026RefStruct {\n    bytes: \u0026bytes,\n    str_s: message,\n}).unwrap();\n\nassert_eq!(\n    \u0026[0x04, 0x01, 0x10, 0x02, 0x20, 0x05, b'h', b'E', b'l', b'L', b'o',],\n    output.deref()\n);\n\nlet out: RefStruct = from_bytes(output.deref()).unwrap();\nassert_eq!(\n    out,\n    RefStruct {\n        bytes: \u0026bytes,\n        str_s: message,\n    }\n);\n```\n\nOr the optional `alloc` feature to serialize to an `alloc::vec::Vec\u003cu8\u003e`:\n\n```rust\nuse core::ops::Deref;\nuse serde::{Serialize, Deserialize};\nuse postcard::{from_bytes, to_allocvec};\nextern crate alloc;\nuse alloc::vec::Vec;\n\n#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]\nstruct RefStruct\u003c'a\u003e {\n    bytes: \u0026'a [u8],\n    str_s: \u0026'a str,\n}\nlet message = \"hElLo\";\nlet bytes = [0x01, 0x10, 0x02, 0x20];\nlet output: Vec\u003cu8\u003e = to_allocvec(\u0026RefStruct {\n    bytes: \u0026bytes,\n    str_s: message,\n}).unwrap();\n\nassert_eq!(\n    \u0026[0x04, 0x01, 0x10, 0x02, 0x20, 0x05, b'h', b'E', b'l', b'L', b'o',],\n    output.deref()\n);\n\nlet out: RefStruct = from_bytes(output.deref()).unwrap();\nassert_eq!(\n    out,\n    RefStruct {\n        bytes: \u0026bytes,\n        str_s: message,\n    }\n);\n```\n\n## Flavors\n\n`postcard` supports a system called `Flavors`, which are used to modify the way\npostcard serializes or processes serialized data. These flavors act as \"plugins\" or \"middlewares\"\nduring the serialization or deserialization process, and can be combined to obtain complex protocol formats.\n\nSee the documentation of the `ser_flavors` or `de_flavors` modules for more information on usage.\n\n## Setup - `Cargo.toml`\n\nDon't forget to add [the `no-std` subset](https://serde.rs/no-std.html) of `serde` along with `postcard` to the `[dependencies]` section of your `Cargo.toml`!\n\n```toml\n[dependencies]\npostcard = \"1.0.0\"\n\n# By default, `serde` has the `std` feature enabled, which makes it unsuitable for embedded targets\n# disabling default-features fixes this\nserde = { version = \"1.0.*\", default-features = false }\n```\n\n## Unsupported serde attributes\n\nIn the case `serde` attributes are used with `postcard`, the serialization and deserialization\nprocess should be tested extensively as multiple attributes can cause problems.\n\n\u003e See the [tracking issue](https://github.com/jamesmunns/postcard/issues/125)\n\nSome serde attributes break serialization/deserialization like:\n\n- `serde(flatten)`\n- `serde(skip_serializing_if($COND))`\n\nSome attributes can cause silent issues:\n\n- `serde(skip)` Can break deserialization. If used for enum variants, make sure that\nthe skipped fields are the last variants, otherwise `postcard` will attempt to deserialize\nbased on an offsetted discriminant, causing failure, or silent mismatch on C-like enums.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":["Rust","Libraries"],"sub_categories":["Encoding"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesmunns%2Fpostcard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesmunns%2Fpostcard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesmunns%2Fpostcard/lists"}