Skip to main content

Crate facet_path

Crate facet_path 

Source
Expand description

TeamDman-maintained fork of facet-path, published as teamy-facet-path. This fork uses its own Facet crate identities; use matching Teamy packages. Upstream MIT OR Apache-2.0 licensing and attribution are retained. See the release notes.

crates.io documentation MIT/Apache-2.0 licensed Discord

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

These are TeamDman-maintained Teamy Facet packages. Upstream Facet documentation, sponsors, credits, and license notices below are retained as upstream attribution; they do not describe sponsorship or ownership of this fork. Fork source: https://github.com/TeamDman/facet/tree/teamy-main. Upstream source: https://github.com/facet-rs/facet.

§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.

Re-exports§

pub use access::PathAccessError;
pub use walk::ShapeVisitor;
pub use walk::VisitDecision;
pub use walk::WalkStatus;
pub use walk::walk_shape;

Modules§

access
Error types for path-based value access.
walk
Shape-only visitor API for deterministic traversal of Shape trees.

Structs§

Path
A path through a type structure, recorded as a series of steps.

Enums§

PathStep
A single step in a path through a type structure.