facet-postcard

Crates.iofacet-postcard
lib.rsfacet-postcard
version0.43.2
created_at2025-12-11 16:57:18.005979+00
updated_at2026-01-23 18:04:45.490264+00
descriptionPostcard binary format for facet with Tier-0 and Tier-2 JIT deserialization
homepagehttps://facet.rs
repositoryhttps://github.com/facet-rs/facet
max_upload_size
id1980132
size418,276
Amos Wenger (fasterthanlime)

documentation

README

facet-postcard

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

facet-postcard

Postcard binary format for facet with Tier-0 and Tier-2 JIT deserialization support.

Wire Compatibility

For statically-typed structs, enums, and primitives, facet-postcard produces wire-compatible output with the standard postcard crate. You can serialize with facet-postcard and deserialize with serde's postcard (and vice versa), as long as both sides agree on the schema.

Dynamic Values (facet_value::Value)

Warning: Value serialization uses a facet-specific tagged encoding that is NOT compatible with standard postcard.

Since postcard is not a self-describing format, there's no standard way to serialize dynamic/any values. facet-postcard solves this by prefixing each Value with a type tag byte:

Tag Type Encoding
0 Null (no payload)
1 Bool 1 byte (0 or 1)
2 I64 zigzag varint
3 U64 varint
4 F64 8 bytes little-endian
5 String varint length + UTF-8 bytes
6 Bytes varint length + raw bytes
7 Array varint count + tagged elements recursively
8 Object varint count + (string key, tagged value) pairs
9 DateTime string (RFC3339)

This means:

  • You cannot deserialize facet-postcard Value bytes using serde's postcard
  • You cannot serialize with serde's postcard and deserialize as Value with facet-postcard
  • Both sides of an RPC/serialization boundary must use facet-postcard when Value is involved

Example wire format for {"name": "Alice", "age": 30}:

08                      # tag 8 = Object
02                      # 2 entries
04 6e 61 6d 65          # key: string "name" (len=4)
05                      # tag 5 = String
05 41 6c 69 63 65       # value: string "Alice" (len=5)
03 61 67 65             # key: string "age" (len=3)
03                      # tag 3 = U64
1e                      # value: varint 30

Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

...along with corporate sponsors:

AWS Zed Depot

...without whom this work could not exist.

Special thanks

The facet logo was drawn by Misiasart.

License

Licensed under either of:

at your option.

Commit count: 3380

cargo fmt