Enum ErrMode
enum ErrMode<E>
Add parse error state to ParserErrors
Needed for
- [
Partial][crate::stream::Partial] to track whether theStreamisErrMode::Incomplete. See also [_topic/partial] - Marking errors as unrecoverable (
ErrMode::Cut) and not retrying alternative parsers. See also [_tutorial/chapter_7#error-cuts]
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
Streamis [partial]crate::stream::StreamIsPartial, like with [Partial][crate::Partial]Convert this into an
BacktrackwithParser::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 fromErrMode::BacktracktoErrMode::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) -> boolTests if the result is Incomplete
fn cut(self: Self) -> SelfPrevent backtracking, bubbling the error up to the top
fn backtrack(self: Self) -> SelfEnable backtracking support
fn map<E2, F>(self: Self, f: F) -> ErrMode<E2> where F: FnOnce(E) -> E2Applies 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)forErrMode::Incomplete
impl<T: Clone> ErrMode<InputError<T>>
fn map_input<U: Clone, F>(self: Self, f: F) -> ErrMode<InputError<U>> where F: FnOnce(T) -> UMaps
ErrMode<InputError<T>>toErrMode<InputError<U>>with the givenF: 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) -> Selffn 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) -> Selffn assert(input: &I, message: &'static str) -> Self where I: Debugfn incomplete(_input: &I, needed: Needed) -> Selffn append(self: Self, input: &I, token_start: &<I as Stream>::Checkpoint) -> Selffn or(self: Self, other: Self) -> Selffn is_backtrack(self: &Self) -> boolfn into_inner(self: Self) -> Result<<Self as >::Inner, Self>fn is_incomplete(self: &Self) -> boolfn 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) -> TReturns the argument unchanged.
impl<T, U> Into for ErrMode<E>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>