pub struct Path {
pub shape: &'static Shape,
pub steps: Vec<PathStep>,
}Expand description
A path through a type structure, recorded as a series of steps.
This is a lightweight representation that only stores indices.
The actual field names and type information can be reconstructed
by replaying these steps against the original Shape.
Fields§
§shape: &'static ShapeThe root Shape from which this path originates.
steps: Vec<PathStep>The sequence of PathSteps representing navigation through the type structure.
Implementations§
Source§impl Path
impl Path
Sourcepub fn with_capacity(shape: &'static Shape, capacity: usize) -> Self
pub fn with_capacity(shape: &'static Shape, capacity: usize) -> Self
Create a path with pre-allocated capacity.
Sourcepub fn format(&self) -> String
pub fn format(&self) -> String
Format this path as a human-readable string using the stored root shape.
Returns a path like outer.inner.items[3].name.
Sourcepub fn format_with_shape(&self, shape: &'static Shape) -> String
pub fn format_with_shape(&self, shape: &'static Shape) -> String
Format this path as a human-readable string by walking the given shape.
Returns a path like outer.inner.items[3].name.
Sourcepub fn resolve_leaf_field(
&self,
shape: &'static Shape,
) -> Option<&'static Field>
pub fn resolve_leaf_field( &self, shape: &'static Shape, ) -> Option<&'static Field>
Resolve the field at the end of this path, if the path ends at a struct field.
This navigates through the given shape following each step in the path,
and returns the Field if the final step is a PathStep::Field.
This is useful for accessing field metadata like attributes when handling errors that occur at a specific field location.
§Returns
Some(&Field)if the path ends at a struct fieldNoneif the path is empty, doesn’t end at a field, or navigation fails