winnow::error

Struct InputError

Source
pub struct InputError<I: Clone> {
    pub input: I,
    pub kind: ErrorKind,
}
Expand description

Capture input on error

This is useful for testing of generic parsers to ensure the error happens at the right location.

Note: context and inner errors (like from Parser::try_map) will be dropped.

Fields§

§input: I

The input stream, pointing to the location where the error occurred

§kind: ErrorKind

A rudimentary error kind

Implementations§

Source§

impl<I: Clone> InputError<I>

Source

pub fn new(input: I, kind: ErrorKind) -> Self

Creates a new basic error

Source

pub fn map_input<I2: Clone, O: Fn(I) -> I2>(self, op: O) -> InputError<I2>

Translate the input type

Source§

impl<'i, I: ToOwned> InputError<&'i I>
where <I as ToOwned>::Owned: Clone,

Source

pub fn into_owned(self) -> InputError<<I as ToOwned>::Owned>

Available on crate feature alloc only.

Obtaining ownership

Trait Implementations§

Source§

impl<I: Stream + Clone, C> AddContext<I, C> for InputError<I>

Source§

fn add_context( self, _input: &I, _token_start: &<I as Stream>::Checkpoint, _context: C, ) -> Self

Append to an existing error custom data Read more
Source§

impl<I: Clone + Clone> Clone for InputError<I>

Source§

fn clone(&self) -> InputError<I>

Returns a copy 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<I: Debug + Clone> Debug for InputError<I>

Source§

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

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

impl<I: Clone + Display> Display for InputError<I>

The Display implementation allows the std::error::Error implementation

Source§

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

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

impl<I: Clone + Debug + Display + Sync + Send + 'static> Error for InputError<I>

Available on crate feature std only.
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
Source§

impl<I: Clone> ErrorConvert<InputError<(I, usize)>> for InputError<I>

Source§

fn convert(self) -> InputError<(I, usize)>

Transform to another error type
Source§

impl<I: Clone> ErrorConvert<InputError<I>> for InputError<(I, usize)>

Source§

fn convert(self) -> InputError<I>

Transform to another error type
Source§

impl<I: Clone, E> FromExternalError<I, E> for InputError<I>

Source§

fn from_external_error(input: &I, kind: ErrorKind, _e: E) -> Self

Create a new error from an input position and an external error

Source§

impl<I: Stream + Clone> ParserError<I> for InputError<I>

Source§

fn from_error_kind(input: &I, kind: ErrorKind) -> Self

Creates an error from the input position and an ErrorKind
Source§

fn append( self, _input: &I, _token_start: &<I as Stream>::Checkpoint, _kind: ErrorKind, ) -> Self

Like ParserError::from_error_kind but merges it with the existing error. Read more
Source§

fn assert(input: &I, _message: &'static str) -> Self
where I: Debug,

Process a parser assertion
Source§

fn or(self, other: Self) -> Self

Combines errors from two different parse branches. Read more
Source§

impl<I: PartialEq + Clone> PartialEq for InputError<I>

Source§

fn eq(&self, other: &InputError<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Copy + Clone> Copy for InputError<I>

Source§

impl<I: Eq + Clone> Eq for InputError<I>

Source§

impl<I: Clone> StructuralPartialEq for InputError<I>

Auto Trait Implementations§

§

impl<I> Freeze for InputError<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for InputError<I>
where I: RefUnwindSafe,

§

impl<I> Send for InputError<I>
where I: Send,

§

impl<I> Sync for InputError<I>
where I: Sync,

§

impl<I> Unpin for InputError<I>
where I: Unpin,

§

impl<I> UnwindSafe for InputError<I>
where I: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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§

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

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.