#reflection #path #facet

no-std facet-path

Path tracking for navigating Facet type structures

11 releases (7 breaking)

Uses new Rust 2024

new 0.44.1 Mar 3, 2026
0.43.2 Jan 23, 2026
0.41.0 Dec 31, 2025

#1849 in Rust patterns

Download history 72/week @ 2026-01-01 382/week @ 2026-01-08 1195/week @ 2026-01-15 1084/week @ 2026-01-22 907/week @ 2026-01-29 672/week @ 2026-02-05 608/week @ 2026-02-12 513/week @ 2026-02-19 939/week @ 2026-02-26

2,830 downloads per month
Used in 87 crates (7 directly)

MIT/Apache

1MB
20K SLoC

facet-path

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

facet-path

Path tracking for navigating Facet type structures.

This crate provides lightweight path tracking that records navigation steps through a Facet type hierarchy. When an error occurs during serialization or deserialization, the path can be used to produce helpful error messages showing exactly where in the data structure the problem occurred.

Features

  • Lightweight PathStep enum that stores indices, not strings
  • Reconstruct human-readable paths by replaying steps against a Shape
  • Optional pretty feature for rich error rendering with facet-pretty

Usage

use facet::Facet;
use facet_path::{Path, PathStep};

#[derive(Facet)]
struct Outer {
    items: Vec<Inner>,
}

#[derive(Facet)]
struct Inner {
    name: String,
    value: u32,
}

// Build a path during traversal
let mut path = Path::new(<Outer as Facet>::SHAPE);
path.push(PathStep::Field(0));      // "items"
path.push(PathStep::Index(2));       // [2]
path.push(PathStep::Field(0));      // "name"

// Format the path as a human-readable string
let formatted = path.format();
assert_eq!(formatted, "items[2].name");

Feature Flags

  • std (default): Enables standard library support
  • alloc: Enables heap allocation without full std
  • pretty: Enables rich error rendering with facet-pretty

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.

Dependencies