Struct winnow::error::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>

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>

1.30.0 · source§

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

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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§

default 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> CloneToUninit for T
where T: Copy,

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,

§

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>,

§

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>,

§

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.