pub struct Path { /* private fields */ }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.
Implementations§
Source§impl Path
impl Path
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a path with pre-allocated capacity.
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnwindSafe for Path
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more