84 releases (29 breaking)
Uses new Rust 2024
| new 0.50.0-rc.0 | Jun 9, 2026 |
|---|---|
| 0.46.0 | Apr 15, 2026 |
| 0.44.5 | Mar 16, 2026 |
| 0.41.0 | Dec 31, 2025 |
| 0.28.0 | Jul 25, 2025 |
#2937 in Parser implementations
Used in 3 crates
640KB
12K
SLoC
facet-msgpack
MsgPack binary format for facet.
This crate provides serialization and deserialization for the MessagePack binary format.
Serialization
use facet::Facet;
use facet_msgpack::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 are two deserialization functions:
from_slice: Deserializes into owned types (T: Facet<'static>)from_slice_borrowed: Deserializes with zero-copy borrowing from the input bufferfrom_slice_into: Deserializes into an existingPartial(type-erased, owned)from_slice_into_borrowed: Deserializes into an existingPartial(type-erased, zero-copy)
use facet::Facet;
use facet_msgpack::from_slice;
#[derive(Facet, Debug, PartialEq)]
struct Point { x: i32, y: i32 }
// MsgPack encoding of {"x": 10, "y": 20}
let bytes = &[0x82, 0xa1, b'x', 0x0a, 0xa1, b'y', 0x14];
let point: Point = from_slice(bytes).unwrap();
assert_eq!(point.x, 10);
assert_eq!(point.y, 20);
Both functions use Tier-2 JIT for compatible types (when the jit feature is enabled),
with automatic fallback to Tier-0 reflection for all other types.
Dependencies
~3.5MB
~59K SLoC