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§

Tests if the result is Incomplete

Prevent backtracking, bubbling the error up to the top

Enable backtracking support

Applies the given function to the inner error

Automatically converts between errors if the underlying type supports it

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

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Like ParseError::from_error_kind but also include an external error.
Creates an error from the input position and an ErrorKind
Process a parser assertion
Like ParseError::from_error_kind but merges it with the existing error. Read more
Combines errors from two different parse branches. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.