facet-postcard 0.44.3

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

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::Facet;
use facet_postcard::to_vec;

#[derive(Facet)]
struct Point { x: i32, y: i32 }

let point = Point { x: 10, y: 20 };
let bytes = to_vec(&point).unwrap();

Deserialization

There is a configurable Deserializer API plus convenience functions:

use facet_postcard::from_slice;

// Postcard encoding: [length=3, true, false, true]
let bytes = &[0x03, 0x01, 0x00, 0x01];
let result: Vec<bool> = from_slice(bytes).unwrap();
assert_eq!(result, vec![true, false, true]);

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.