Trait ParserError

trait ParserError<I: Stream>: Sized

The basic Parser trait for errors

It provides methods to create an error from some combinators, and combine existing errors in combinators like alt.

Associated Types

type Inner

Generally, Self

Mostly used for ErrMode

Required Methods

fn from_input(input: &I) -> Self

Creates an error from the input position

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

Unwrap the mode, returning the underlying error, if present

Provided Methods

fn assert(input: &I, _message: &'static str) -> Self
where
    I: Debug

Process a parser assertion

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]crate::stream::StreamIsPartial, like with [Partial][crate::Partial]

Convert this into an Backtrack with Parser::complete_err

fn append(self: 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.

fn or(self: Self, other: Self) -> Self

Combines errors from two different parse branches.

For example, this would be used by [alt][crate::combinator::alt] to report the error from each case.

fn is_backtrack(self: &Self) -> bool

Is backtracking and trying new parse branches allowed?

fn is_incomplete(self: &Self) -> bool

Is more data Needed

This must be the same as [err.needed().is_some()][ParserError::needed]

fn needed(self: &Self) -> Option<Needed>

Extract the Needed data, if present

Self::needed().is_some() must be the same as [err.is_incomplete()][ParserError::is_incomplete]

Implementors