facet-postcard
Postcard binary format for facet.
This crate provides serialization and deserialization for the postcard binary format.
Serialization
Serialization supports all types that implement facet_core::Facet:
use Facet;
use to_vec;
let point = Point ;
let bytes = to_vec.unwrap;
Deserialization
There is a configurable Deserializer API plus convenience functions:
from_slice: Deserializes into owned types (T: Facet<'static>)from_slice_borrowed: Deserializes with zero-copy borrowing from the input bufferfrom_slice_with_shape: Deserializes intoValueusing runtime shape informationfrom_slice_into: Deserializes into an existingPartial(type-erased, owned)from_slice_into_borrowed: Deserializes into an existingPartial(type-erased, zero-copy)
use from_slice;
// Postcard encoding: [length=3, true, false, true]
let bytes = &;
let result: = from_slice.unwrap;
assert_eq!;
Both functions automatically select the best deserialization tier:
- Tier-2 (Format JIT): Fastest path for compatible types (primitives, structs, vecs, simple enums)
- Tier-0 (Reflection): Fallback for all other types (nested enums, complex types)
This ensures all Facet types can be deserialized.