Skip to main content

PathAccessError

Enum PathAccessError 

Source
#[non_exhaustive]
pub enum PathAccessError { RootShapeMismatch { expected: &'static Shape, actual: &'static Shape, }, WrongStepKind { step: PathStep, step_index: usize, shape: &'static Shape, }, IndexOutOfBounds { step: PathStep, step_index: usize, shape: &'static Shape, index: usize, bound: usize, }, VariantMismatch { step_index: usize, shape: &'static Shape, expected_variant: usize, actual_variant: usize, }, MissingTarget { step: PathStep, step_index: usize, shape: &'static Shape, }, OptionIsNone { step_index: usize, shape: &'static Shape, }, }
Expand description

Error returned when navigating a value using a Path.

Each variant captures enough context for a caller to produce a meaningful diagnostic without re-walking the path.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

RootShapeMismatch

The root shape of the path doesn’t match the value being navigated.

Fields

§expected: &'static Shape

The shape recorded in the path.

§actual: &'static Shape

The shape of the value we tried to navigate.

§

WrongStepKind

The step kind doesn’t apply to the current shape.

For example, PathStep::Field on a scalar, or PathStep::Index on a struct.

Fields

§step: PathStep

The step that didn’t apply.

§step_index: usize

Index of this step in the path (0-based).

§shape: &'static Shape

The shape at the point where the step was attempted.

§

IndexOutOfBounds

A field or list index is out of bounds.

Fields

§step: PathStep

The step that contained the out-of-bounds index.

§step_index: usize

Index of this step in the path (0-based).

§shape: &'static Shape

The shape of the container.

§index: usize

The index that was requested.

§bound: usize

The number of available items (fields, elements, variants, etc.).

§

VariantMismatch

The path says we should be at variant X, but the live value is variant Y.

Fields

§step_index: usize

Index of this step in the path (0-based).

§shape: &'static Shape

The enum shape.

§expected_variant: usize

The variant index the path expected.

§actual_variant: usize

The variant index found at runtime.

§

MissingTarget

A Deref, Inner, or Proxy step has no target.

This can happen when a smart pointer has no borrow_fn, or the shape has no inner, or no proxy definition.

Fields

§step: PathStep

The step that required a target.

§step_index: usize

Index of this step in the path (0-based).

§shape: &'static Shape

The shape that was expected to provide a target.

§

OptionIsNone

An OptionSome step was encountered but the value is None.

Fields

§step_index: usize

Index of this step in the path (0-based).

§shape: &'static Shape

The option shape.

Trait Implementations§

Source§

impl Clone for PathAccessError

Source§

fn clone(&self) -> PathAccessError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PathAccessError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PathAccessError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for PathAccessError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.