Enum winnow::error::ErrMode

source ·
pub enum ErrMode<E> {
    Incomplete(Needed),
    Backtrack(E),
    Cut(E),
}
Expand description

The Err enum indicates the parser was not successful

Variants§

§

Incomplete(Needed)

There was not enough data to determine the appropriate action

More data needs to be buffered before retrying the parse.

This must only be set when the Stream is partial, like with Partial

Convert this into an Backtrack with Parser::complete_err

§

Backtrack(E)

The parser failed with a recoverable error (the default).

For example, a parser for json values might include a dec_uint as one case in an alt combiantor. If it fails, the next case should be tried.

§

Cut(E)

The parser had an unrecoverable error.

The parser was on the right branch, so directly report it to the user rather than trying other branches. You can use cut_err() combinator to switch from ErrMode::Backtrack to ErrMode::Cut.

For example, one case in an alt combinator found a unique prefix and you want any further errors parsing the case to be reported to the user.

Implementations§

source§

impl<E> ErrMode<E>

source

pub fn is_incomplete(&self) -> bool

Tests if the result is Incomplete

source

pub fn cut(self) -> Self

Prevent backtracking, bubbling the error up to the top

source

pub fn backtrack(self) -> Self

Enable backtracking support

source

pub fn map<E2, F>(self, f: F) -> ErrMode<E2>where F: FnOnce(E) -> E2,

Applies the given function to the inner error

source

pub fn convert<F>(self) -> ErrMode<F>where E: ErrorConvert<F>,

Automatically converts between errors if the underlying type supports it

source§

impl<T> ErrMode<Error<T>>

source

pub fn map_input<U, F>(self, f: F) -> ErrMode<Error<U>>where F: FnOnce(T) -> U,

Maps ErrMode<Error<T>> to ErrMode<Error<U>> with the given F: T -> U

Trait Implementations§

source§

impl<E: Clone> Clone for ErrMode<E>

source§

fn clone(&self) -> ErrMode<E>

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<E: Debug> Debug for ErrMode<E>

source§

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

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

impl<E> Display for ErrMode<E>where E: Debug,

source§

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

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

impl<I, EXT, E> FromExternalError<I, EXT> for ErrMode<E>where E: FromExternalError<I, EXT>,

source§

fn from_external_error(input: I, kind: ErrorKind, e: EXT) -> Self

Like ParseError::from_error_kind but also include an external error.
source§

impl<I, E: ParseError<I>> ParseError<I> for ErrMode<E>

source§

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

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

fn assert(input: I, message: &'static str) -> Selfwhere I: Debug,

Process a parser assertion
source§

fn append(self, input: I, kind: ErrorKind) -> Self

Like ParseError::from_error_kind but merges it with the existing error. Read more
source§

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

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

impl<E: PartialEq> PartialEq<ErrMode<E>> for ErrMode<E>

source§

fn eq(&self, other: &ErrMode<E>) -> 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<E: Eq> Eq for ErrMode<E>

source§

impl<E> StructuralPartialEq for ErrMode<E>

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for ErrMode<E>where E: RefUnwindSafe,

§

impl<E> Send for ErrMode<E>where E: Send,

§

impl<E> Sync for ErrMode<E>where E: Sync,

§

impl<E> Unpin for ErrMode<E>where E: Unpin,

§

impl<E> UnwindSafe for ErrMode<E>where E: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.