Trait combine::ParseError

source ·
pub trait ParseError<Item, Range, Position>: Sized + PartialEq {
    type StreamError: StreamError<Item, Range>;

Show 13 methods // Required methods fn empty(position: Position) -> Self; fn set_position(&mut self, position: Position); fn add(&mut self, err: Self::StreamError); fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F) where F: FnOnce(&mut Tracked<Self>); fn is_unexpected_end_of_input(&self) -> bool; fn into_other<T>(self) -> T where T: ParseError<Item, Range, Position>; // Provided methods fn from_error(position: Position, err: Self::StreamError) -> Self { ... } fn position(&self) -> Position { ... } fn merge(self, other: Self) -> Self { ... } fn add_expected<E>(&mut self, info: E) where E: for<'s> ErrorInfo<'s, Item, Range> { ... } fn add_unexpected<E>(&mut self, info: E) where E: for<'s> ErrorInfo<'s, Item, Range> { ... } fn add_message<E>(&mut self, info: E) where E: for<'s> ErrorInfo<'s, Item, Range> { ... } fn clear_expected(&mut self) { ... }
}
Expand description

Trait which defines a combine parse error.

A parse error is composed of zero or more StreamError instances which gets added to it as errors are encountered during parsing.

Required Associated Types§

source

type StreamError: StreamError<Item, Range>

Required Methods§

source

fn empty(position: Position) -> Self

Constructs an empty error.

An empty error is expected to be cheap to create as it is frequently created and discarded.

source

fn set_position(&mut self, position: Position)

Sets the position of this ParseError

source

fn add(&mut self, err: Self::StreamError)

Adds a StreamError to self.

It is up to each individual error type to define what adding an error does, some may push it to a vector while others may only keep self or err to avoid allocation

source

fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F)
where F: FnOnce(&mut Tracked<Self>),

Sets info as the only Expected error of self

source

fn is_unexpected_end_of_input(&self) -> bool

source

fn into_other<T>(self) -> T
where T: ParseError<Item, Range, Position>,

Does a best-effort conversion of self into another ParseError

Provided Methods§

source

fn from_error(position: Position, err: Self::StreamError) -> Self

Creates a ParseError from a single Self::StreamError

source

fn position(&self) -> Position

source

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

Merges two errors. If they exist at the same position the errors of other are added to self (using the semantics of add). If they are not at the same position the error furthest ahead are returned, ignoring the other ParseError.

source

fn add_expected<E>(&mut self, info: E)
where E: for<'s> ErrorInfo<'s, Item, Range>,

source

fn add_unexpected<E>(&mut self, info: E)
where E: for<'s> ErrorInfo<'s, Item, Range>,

source

fn add_message<E>(&mut self, info: E)
where E: for<'s> ErrorInfo<'s, Item, Range>,

source

fn clear_expected(&mut self)

Removes any expected errors currently in self

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Item, Range, Position> ParseError<Item, Range, Position> for StringStreamError
where Position: Default,

source§

impl<Item, Range, Position> ParseError<Item, Range, Position> for UnexpectedParse
where Position: Default,

source§

impl<Item, Range, Position> ParseError<Item, Range, Position> for combine::stream::easy::Error<Item, Range>
where Item: PartialEq, Range: PartialEq, Position: Default,

Available on crate feature std only.
§

type StreamError = Error<Item, Range>

source§

impl<Item, Range, Position> ParseError<Item, Range, Position> for combine::stream::read::Error
where Position: Default,

Available on crate feature std only.
source§

impl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Item, Range, Position>
where Item: PartialEq, Range: PartialEq, Position: Ord + Clone,

Available on crate feature std only.
§

type StreamError = Error<Item, Range>