Enum ParseFailure

Source
pub enum ParseFailure<'a> {
    Error(ParseError<'a>),
    Unrecognized(UnrecognizedToken<'a>),
}
Expand description

Value’s failed parsing result

The parsing process can fail in two different ways:

  • The input stream contains invalid tokens: the number, order, or contents of tokens is incorrect. Such errors are represented by the ParseError struct.
  • The input may be correct, but the current parser does not recognize the input stream’s first token. In such case, another parser may recognize this token. Such situations arise when dealing with optional fields, variable number of fields, etc. Such situations are represented by the UnexpectedToken struct.

ParseFailure enum’s variants encapsulates both these structs.

Variants§

§

Error(ParseError<'a>)

The parsing failed with an unrecoverable error

§

Unrecognized(UnrecognizedToken<'a>)

The token is not recognized by the parser

Implementations§

Source§

impl<'a> ParseFailure<'a>

Source

pub fn as_error(&self) -> Option<&ParseError<'a>>

Returns a reference to the ParseError if this ParseFailure corresponds to an error or None otherwise.

Source

pub fn as_unrecognized(&self) -> Option<&UnrecognizedToken<'a>>

Returns a reference to the UnrecognizedToken if this ParseFailure corresponds to a failure due to an unrecognized token or None otherwise.

Trait Implementations§

Source§

impl<'a> Debug for ParseFailure<'a>

Source§

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

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

impl<'a, E: Into<ParseError<'a>>> From<E> for ParseFailure<'a>

Source§

fn from(error: E) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<UnrecognizedToken<'a>> for ParseFailure<'a>

Source§

fn from(unrecognized: UnrecognizedToken<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for ParseFailure<'a>

§

impl<'a> RefUnwindSafe for ParseFailure<'a>

§

impl<'a> Send for ParseFailure<'a>

§

impl<'a> Sync for ParseFailure<'a>

§

impl<'a> Unpin for ParseFailure<'a>

§

impl<'a> UnwindSafe for ParseFailure<'a>

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, 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> ParsableTransformation<Box<T>> for T

Source§

type Input = T

The type that will be transformed by the implementation if this trait (Self::Input -> O).
Source§

fn transform( input: <T as ParsableTransformation<Box<T>>>::Input, ) -> Result<Box<T>, ParseError<'static>>

Performs the transformation.
Source§

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

Source§

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>,

Source§

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.