pub enum ErrMode<E> {
Incomplete(Needed),
Backtrack(E),
Cut(E),
}
Expand description
Add parse error state to ParserError
s
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
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()
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>
impl<E> ErrMode<E>
Sourcepub fn is_incomplete(&self) -> bool
pub fn is_incomplete(&self) -> bool
Tests if the result is Incomplete
Sourcepub fn map<E2, F>(self, f: F) -> ErrMode<E2>where
F: FnOnce(E) -> E2,
pub fn map<E2, F>(self, f: F) -> ErrMode<E2>where
F: FnOnce(E) -> E2,
Applies the given function to the inner error
Sourcepub fn convert<F>(self) -> ErrMode<F>where
E: ErrorConvert<F>,
pub fn convert<F>(self) -> ErrMode<F>where
E: ErrorConvert<F>,
Automatically converts between errors if the underlying type supports it
Sourcepub fn into_inner(self) -> Option<E>
pub fn into_inner(self) -> Option<E>
Unwrap the mode, returning the underlying error
Returns None
for ErrMode::Incomplete
Trait Implementations§
Source§impl<I: Stream, C, E: AddContext<I, C>> AddContext<I, C> for ErrMode<E>
impl<I: Stream, C, E: AddContext<I, C>> AddContext<I, C> for ErrMode<E>
Source§fn add_context(
self,
input: &I,
token_start: &<I as Stream>::Checkpoint,
context: C,
) -> Self
fn add_context( self, input: &I, token_start: &<I as Stream>::Checkpoint, context: C, ) -> Self
Source§impl<I, EXT, E> FromExternalError<I, EXT> for ErrMode<E>where
E: FromExternalError<I, EXT>,
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
fn from_external_error(input: &I, kind: ErrorKind, e: EXT) -> Self
ParserError::from_error_kind
but also include an external error.Source§impl<I: Stream, E: ParserError<I>> ParserError<I> for ErrMode<E>
impl<I: Stream, E: ParserError<I>> ParserError<I> for ErrMode<E>
Source§fn from_error_kind(input: &I, kind: ErrorKind) -> Self
fn from_error_kind(input: &I, kind: ErrorKind) -> Self
ErrorKind
Source§fn append(
self,
input: &I,
token_start: &<I as Stream>::Checkpoint,
kind: ErrorKind,
) -> Self
fn append( self, input: &I, token_start: &<I as Stream>::Checkpoint, kind: ErrorKind, ) -> Self
ParserError::from_error_kind
but merges it with the existing error. Read more