Enum ErrMode

enum ErrMode<E>

Add parse error state to ParserErrors

Needed for

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]crate::stream::StreamIsPartial, like with [Partial][crate::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][crate::ascii::dec_uint] as one case in an [alt][crate::combinator::alt] combinator. 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()][crate::combinator::cut_err] combinator to switch from ErrMode::Backtrack to ErrMode::Cut.

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

Implementations

impl<E> ErrMode<E>

fn is_incomplete(self: &Self) -> bool

Tests if the result is Incomplete

fn cut(self: Self) -> Self

Prevent backtracking, bubbling the error up to the top

fn backtrack(self: Self) -> Self

Enable backtracking support

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

Applies the given function to the inner error

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

Automatically converts between errors if the underlying type supports it

fn into_inner(self: Self) -> Result<E, Self>

Unwrap the mode, returning the underlying error

Returns Err(self) for ErrMode::Incomplete

impl<T: Clone> ErrMode<InputError<T>>

fn map_input<U: Clone, F>(self: Self, f: F) -> ErrMode<InputError<U>>
where
    F: FnOnce(T) -> U

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

impl<E> Display for ErrMode<E>

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

impl<E> Freeze for ErrMode<E>

impl<E> ModalError for ErrMode<E>

fn cut(self: Self) -> Self
fn backtrack(self: Self) -> Self

impl<E> RefUnwindSafe for ErrMode<E>

impl<E> Send for ErrMode<E>

impl<E> StructuralPartialEq for ErrMode<E>

impl<E> Sync for ErrMode<E>

impl<E> Unpin for ErrMode<E>

impl<E> UnsafeUnpin for ErrMode<E>

impl<E> UnwindSafe for ErrMode<E>

impl<E1, E2> ErrorConvert for ErrMode<E1>

fn convert(self: Self) -> ErrMode<E2>

impl<E: $crate::clone::Clone> Clone for ErrMode<E>

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

impl<E: $crate::cmp::PartialEq> PartialEq for ErrMode<E>

fn eq(self: &Self, other: &ErrMode<E>) -> bool

impl<E: $crate::fmt::Debug> Debug for ErrMode<E>

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

impl<E: Eq> Eq for ErrMode<E>

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

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

impl<I: Stream, C, E: AddContext<I, C>> AddContext for ErrMode<E>

fn add_context(self: Self, input: &I, token_start: &<I as Stream>::Checkpoint, context: C) -> Self

impl<I: Stream, E: ParserError<I>> ParserError for ErrMode<E>

fn from_input(input: &I) -> Self
fn assert(input: &I, message: &'static str) -> Self
where
    I: Debug
fn incomplete(_input: &I, needed: Needed) -> Self
fn append(self: Self, input: &I, token_start: &<I as Stream>::Checkpoint) -> Self
fn or(self: Self, other: Self) -> Self
fn is_backtrack(self: &Self) -> bool
fn into_inner(self: Self) -> Result<<Self as >::Inner, Self>
fn is_incomplete(self: &Self) -> bool
fn needed(self: &Self) -> Option<Needed>

impl<T> Any for ErrMode<E>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ErrMode<E>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ErrMode<E>

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

impl<T> CloneToUninit for ErrMode<E>

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

impl<T> From for ErrMode<E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for ErrMode<E>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for ErrMode<E>

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

impl<T, U> TryInto for ErrMode<E>

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