ParserError

Trait ParserError 

Source
pub trait ParserError<I>: Sized
where I: Stream,
{ // Required methods fn from_error_kind(input: &I, kind: ErrorKind) -> Self; fn append( self, input: &I, token_start: &<I as Stream>::Checkpoint, kind: ErrorKind, ) -> Self; // Provided methods fn from_input(input: &I) -> Self { ... } fn assert(input: &I, _message: &'static str) -> Self where I: Debug { ... } fn or(self, other: Self) -> Self { ... } }
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 Methods§

Source

fn from_error_kind(input: &I, kind: ErrorKind) -> Self

👎Deprecated since 0.6.26: replaced with ParserError::from_input

Deprecated, replaced with ParserError::from_input

Source

fn append( self, input: &I, token_start: &<I as Stream>::Checkpoint, kind: ErrorKind, ) -> Self

Like ParserError::from_error_kind but merges it with the existing error.

This is useful when backtracking through a parse tree, accumulating error context on the way.

Provided Methods§

Source

fn from_input(input: &I) -> Self

Creates an error from the input position

Source

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

Process a parser assertion

Source

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.

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> ParserError<I> for ()
where I: Stream,

Source§

fn from_error_kind(_: &I, _: ErrorKind)

👎Deprecated since 0.6.26: replaced with ParserError::from_input
Source§

fn append( self, _input: &I, _token_start: &<I as Stream>::Checkpoint, _kind: ErrorKind, )

Implementors§

Source§

impl<I> ParserError<I> for ErrorKind
where I: Stream,

Source§

impl<I> ParserError<I> for EmptyError
where I: Stream,

Source§

impl<I> ParserError<I> for InputError<I>
where I: Stream + Clone,

Source§

impl<I, C> ParserError<I> for TreeError<I, C>
where I: Stream + Clone,

Available on crate feature std only.
Source§

impl<I, C> ParserError<I> for ContextError<C>
where I: Stream,

Source§

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