pub trait ParserError<I: Stream>: Sized {
type Inner;
// Required methods
fn from_input(input: &I) -> Self;
fn into_inner(self) -> Result<Self::Inner, Self>;
// Provided methods
fn assert(input: &I, _message: &'static str) -> Self
where I: Debug { ... }
fn incomplete(input: &I, _needed: Needed) -> Self { ... }
fn append(
self,
_input: &I,
_token_start: &<I as Stream>::Checkpoint,
) -> Self { ... }
fn or(self, other: Self) -> Self { ... }
fn is_backtrack(&self) -> bool { ... }
fn is_incomplete(&self) -> bool { ... }
fn needed(&self) -> Option<Needed> { ... }
}
Expand description
The basic Parser
trait for errors
It provides methods to create an error from some combinators,
and combine existing errors in combinators like alt
.
Required Associated Types§
Required Methods§
Sourcefn from_input(input: &I) -> Self
fn from_input(input: &I) -> Self
Creates an error from the input position
Sourcefn into_inner(self) -> Result<Self::Inner, Self>
fn into_inner(self) -> Result<Self::Inner, Self>
Unwrap the mode, returning the underlying error, if present
Provided Methods§
Sourcefn incomplete(input: &I, _needed: Needed) -> Self
fn incomplete(input: &I, _needed: Needed) -> Self
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
Sourcefn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
Like ParserError::from_input
but merges it with the existing error.
This is useful when backtracking through a parse tree, accumulating error context on the way.
Sourcefn or(self, other: Self) -> Self
fn or(self, other: Self) -> Self
Combines errors from two different parse branches.
For example, this would be used by alt
to report the error from
each case.
Sourcefn is_backtrack(&self) -> bool
fn is_backtrack(&self) -> bool
Is backtracking and trying new parse branches allowed?
Sourcefn is_incomplete(&self) -> bool
fn is_incomplete(&self) -> bool
Is more data Needed
This must be the same as err.needed().is_some()
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<I: Stream> ParserError<I> for ()
impl<I: Stream> ParserError<I> for ()
Implementors§
Source§impl<I, C> ParserError<I> for TreeError<I, C>
Available on crate feature std
only.
impl<I, C> ParserError<I> for TreeError<I, C>
std
only.