Struct combine::stream::easy::Errors

source ·
pub struct Errors<T, R, P> {
    pub position: P,
    pub errors: Vec<Error<T, R>>,
}
Available on crate feature std only.
Expand description

Struct which hold information about an error that occurred at a specific position. Can hold multiple instances of Error if more that one error occurred in the same position.

Fields§

§position: P

The position where the error occurred

§errors: Vec<Error<T, R>>

A vector containing specific information on what errors occurred at position. Usually a fully formed message contains one Unexpected error and one or more Expected errors. Message and Other may also appear (combine never generates these errors on its own) and may warrant custom handling.

Implementations§

source§

impl<T, R, P> Errors<T, R, P>

source

pub fn new(position: P, error: Error<T, R>) -> Errors<T, R, P>

Constructs a new ParseError which occurred at position.

source

pub fn empty(position: P) -> Errors<T, R, P>

Constructs an error with no other information than the position it occurred at.

source

pub fn from_errors(position: P, errors: Vec<Error<T, R>>) -> Errors<T, R, P>

Constructs a ParseError with multiple causes.

source

pub fn end_of_input(position: P) -> Errors<T, R, P>

Constructs an end of input error. Should be returned by parsers which encounter end of input unexpectedly.

source

pub fn add_error(&mut self, error: Error<T, R>)
where T: PartialEq, R: PartialEq,

Adds an error if error does not exist in this ParseError already (as determined byte PartialEq).

source

pub fn set_expected(&mut self, info: Info<T, R>)

Removes all Expected errors in self and adds info instead.

source

pub fn merge(self, other: Errors<T, R, P>) -> Errors<T, R, P>
where P: Ord, T: PartialEq, R: PartialEq,

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

source

pub fn map_position<F, Q>(self, f: F) -> Errors<T, R, Q>
where F: FnOnce(P) -> Q,

Maps the position to a new value

source

pub fn map_token<F, U>(self, f: F) -> Errors<U, R, P>
where F: FnMut(T) -> U,

Maps all token variants to a new value

source

pub fn map_range<F, S>(self, f: F) -> Errors<T, S, P>
where F: FnMut(R) -> S,

Maps all range variants to a new value.

use combine::*;
use combine::parser::range::range;
println!(
    "{}",
    range(&"HTTP"[..])
        .easy_parse("HTT")
        .unwrap_err()
        .map_range(|bytes| format!("{:?}", bytes))
);

Trait Implementations§

source§

impl<T: Debug, R: Debug, P: Debug> Debug for Errors<T, R, P>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, R, P> Display for Errors<T, R, P>
where P: Display, T: Display, R: Display,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, R, P> Error for Errors<T, R, P>
where P: Display + Debug, T: Display + Debug, R: Display + Debug,

source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<'a, P> From<Error<Errors<u8, &'a [u8], P>, P>> for Errors<u8, &'a [u8], P>
where P: Ord + Clone,

source§

fn from(e: Error<Errors<u8, &'a [u8], P>, P>) -> Self

Converts to this type from the input type.
source§

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

§

type StreamError = Error<Item, Range>

source§

fn empty(pos: Position) -> Self

Constructs an empty error. Read more
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 set_position(&mut self, position: Position)

Sets the position of this ParseError
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(&mut self, err: Self::StreamError)

Adds a StreamError to self. Read more
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 clear_expected(&mut self)

Removes any expected errors currently in 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
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§

impl<Item, Range, Position> ParseErrorInto<Item, Range, Position> for Errors<Item, Range, Position>

source§

fn into_other_error<T, Item2, Range2, Position2>(self) -> T
where T: ParseError<Item2, Range2, Position2>, Item2: From<Item>, Range2: From<Range>, Position2: From<Position>,

source§

impl<T: PartialEq, R: PartialEq, P: PartialEq> PartialEq for Errors<T, R, P>

source§

fn eq(&self, other: &Errors<T, R, P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, R, P> StructuralPartialEq for Errors<T, R, P>

Auto Trait Implementations§

§

impl<T, R, P> Freeze for Errors<T, R, P>
where P: Freeze,

§

impl<T, R, P> !RefUnwindSafe for Errors<T, R, P>

§

impl<T, R, P> Send for Errors<T, R, P>
where P: Send, T: Send, R: Send,

§

impl<T, R, P> Sync for Errors<T, R, P>
where P: Sync, T: Sync, R: Sync,

§

impl<T, R, P> Unpin for Errors<T, R, P>
where P: Unpin, T: Unpin, R: Unpin,

§

impl<T, R, P> !UnwindSafe for Errors<T, R, P>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more