Struct combine::primitives::ParseError
[−]
[src]
pub struct ParseError<S: StreamOnce> { pub position: S::Position, pub errors: Vec<Error<S::Item, S::Range>>, }
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: S::Position
The position where the error occurred
errors: Vec<Error<S::Item, S::Range>>
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.
Methods
impl<S: StreamOnce> ParseError<S>
[src]
impl<S: StreamOnce> ParseError<S>
pub fn new(
position: S::Position,
error: Error<S::Item, S::Range>
) -> ParseError<S>
[src]
pub fn new(
position: S::Position,
error: Error<S::Item, S::Range>
) -> ParseError<S>
Constructs a new ParseError
which occurred at position
.
pub fn empty(position: S::Position) -> ParseError<S>
[src]
pub fn empty(position: S::Position) -> ParseError<S>
Constructs an error with no other information than the position it occurred at.
pub fn from_errors(
position: S::Position,
errors: Vec<Error<S::Item, S::Range>>
) -> ParseError<S>
[src]
pub fn from_errors(
position: S::Position,
errors: Vec<Error<S::Item, S::Range>>
) -> ParseError<S>
Constructs a ParseError
with multiple causes.
pub fn end_of_input(position: S::Position) -> ParseError<S>
[src]
pub fn end_of_input(position: S::Position) -> ParseError<S>
Constructs an end of input error. Should be returned by parsers which encounter end of input unexpectedly.
pub fn add_message<M>(&mut self, message: M) where
M: Into<Info<S::Item, S::Range>>,
[src]
pub fn add_message<M>(&mut self, message: M) where
M: Into<Info<S::Item, S::Range>>,
: Use add_error(Error::Message())
instead
Adds a Message
error, taking care not to add duplicated errors.
pub fn add_error(&mut self, error: Error<S::Item, S::Range>)
[src]
pub fn add_error(&mut self, error: Error<S::Item, S::Range>)
Adds an error if error
does not exist in this ParseError
already (as determined byte
PartialEq
).
pub fn set_expected(&mut self, info: Info<S::Item, S::Range>)
[src]
pub fn set_expected(&mut self, info: Info<S::Item, S::Range>)
Remvoes all Expected
errors in self
and adds info
instead.
pub fn merge(self, other: ParseError<S>) -> ParseError<S>
[src]
pub fn merge(self, other: ParseError<S>) -> ParseError<S>
Merges two ParseError
s. 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
.
impl<'s> ParseError<&'s str>
[src]
impl<'s> ParseError<&'s str>
pub fn translate_position(self, initial_string: &'s str) -> ParseError<&'s str>
[src]
pub fn translate_position(self, initial_string: &'s str) -> ParseError<&'s str>
Converts the pointer-based position into an indexed position.
let text = "b"; let err = token('a').parse(text).unwrap_err(); assert_eq!(err.position, text.as_ptr() as usize); assert_eq!(err.translate_position(text).position, 0);
impl<'s, T: 's> ParseError<&'s [T]> where
T: Clone + PartialEq,
[src]
impl<'s, T: 's> ParseError<&'s [T]> where
T: Clone + PartialEq,
pub fn translate_position(self, initial_string: &'s [T]) -> ParseError<&'s [T]>
[src]
pub fn translate_position(self, initial_string: &'s [T]) -> ParseError<&'s [T]>
Converts the pointer-based position into an indexed position.
let text = b"b"; let err = token(b'a').parse(&text[..]).unwrap_err(); assert_eq!(err.position, text.as_ptr() as usize); assert_eq!(err.translate_position(text).position, 0);
Trait Implementations
impl<S> StdError for ParseError<S> where
S: Stream,
S::Range: Display + Debug + Any,
S::Item: Display + Debug + Any,
S::Position: Display + Debug + Any,
[src]
impl<S> StdError for ParseError<S> where
S: Stream,
S::Range: Display + Debug + Any,
S::Item: Display + Debug + Any,
S::Position: Display + Debug + Any,
fn description(&self) -> &str
[src]
fn description(&self) -> &str
A short description of the error. Read more
fn cause(&self) -> Option<&Error>
1.0.0[src]
fn cause(&self) -> Option<&Error>
The lower-level cause of this error, if any. Read more
impl<S> PartialEq for ParseError<S> where
S: Stream,
S::Position: PartialEq,
[src]
impl<S> PartialEq for ParseError<S> where
S: Stream,
S::Position: PartialEq,
fn eq(&self, other: &ParseError<S>) -> bool
[src]
fn eq(&self, other: &ParseError<S>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<S> Debug for ParseError<S> where
S: Stream,
S::Range: Debug,
S::Item: Debug,
S::Position: Debug,
[src]
impl<S> Debug for ParseError<S> where
S: Stream,
S::Range: Debug,
S::Item: Debug,
S::Position: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<S> Display for ParseError<S> where
S: Stream,
S::Item: Display,
S::Range: Display,
S::Position: Display,
[src]
impl<S> Display for ParseError<S> where
S: Stream,
S::Item: Display,
S::Range: Display,
S::Position: Display,
Auto Trait Implementations
impl<S> Send for ParseError<S> where
<S as StreamOnce>::Item: Send,
<S as StreamOnce>::Position: Send,
<S as StreamOnce>::Range: Send,
impl<S> Send for ParseError<S> where
<S as StreamOnce>::Item: Send,
<S as StreamOnce>::Position: Send,
<S as StreamOnce>::Range: Send,
impl<S> Sync for ParseError<S> where
<S as StreamOnce>::Item: Sync,
<S as StreamOnce>::Position: Sync,
<S as StreamOnce>::Range: Sync,
impl<S> Sync for ParseError<S> where
<S as StreamOnce>::Item: Sync,
<S as StreamOnce>::Position: Sync,
<S as StreamOnce>::Range: Sync,