pub struct TokenizerError<C, I> {
    pub code: C,
    pub span: I,
}
Expand description

Shorter error type for the tokenizer stage. Nom parsers fail often, so it’s good to keep this minimal.

Fields§

§code: C

Error code

§span: I

Error span

Implementations§

source§

impl<C, I> TokenizerError<C, I>where C: Code, I: Clone,

source

pub fn new(code: C, span: I) -> Self

New error.

source

pub fn append_err(&mut self, other: TokenizerError<C, I>)

Replaces the information with the other error. Unless the other contains only the generic NOM_ERROR.

source

pub fn with_code(self, code: C) -> Self

Convert to a new error code. If the old one differs, it is added to the expect list.

source

pub fn error(self) -> Err<Self>

Convert to a nom::Err::Error.

source

pub fn failure(self) -> Err<Self>

Convert to a nom::Err::Failure.

Trait Implementations§

source§

impl<C, I> Debug for TokenizerError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

source§

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

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

impl<C, I> Display for TokenizerError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

source§

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

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

impl<C, I> ErrOrNomErr for TokenizerError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = TokenizerError<C, I>

The base error type.
source§

fn wrap(self) -> Err<Self::WrappedError>

Converts self to a nom::Err wrapped error.
source§

impl<C, I> Error for TokenizerError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

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 description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
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<C, I> From<TokenizerError<C, I>> for ParserError<C, I>where C: Code, I: Clone,

source§

fn from(value: TokenizerError<C, I>) -> Self

Converts to this type from the input type.
source§

impl<C, I> KParseError<C, I> for TokenizerError<C, I>where C: Code, I: Clone + Debug + SpanFragment + InputTake + InputLength + InputIter,

§

type WrappedError = TokenizerError<C, I>

The base error type.
source§

fn from(code: C, span: I) -> Self

Create a matching error.
source§

fn with_code(self, code: C) -> Self

Changes the error code.
source§

fn code(&self) -> Option<C>

Returns the error code if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn span(&self) -> Option<I>

Returns the error span if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn err(&self) -> Option<&Self::WrappedError>

Returns the error if self is Result::Err and it’s not nom::Err::Incomplete.
source§

fn parts(&self) -> Option<(C, I, &Self::WrappedError)>

Returns all the parts if self is Result::Err and it’s not nom::Err::Incomplete.
source§

impl<C, I> ParseError<I> for TokenizerError<C, I>where C: Code, I: Clone + Debug + InputTake + InputLength + InputIter,

source§

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

Creates an error from the input position and an ErrorKind
source§

fn append(_input: I, _kind: ErrorKind, other: Self) -> Self

Combines an existing error with a new one created from the input position and an ErrorKind. This is useful when backtracking through a parse tree, accumulating error context on the way
source§

fn from_char(input: I, _char: char) -> Self

Creates an error from an input position and an expected character
source§

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

Combines two existing errors. This function is used to compare errors generated in various branches of alt.

Auto Trait Implementations§

§

impl<C, I> RefUnwindSafe for TokenizerError<C, I>where C: RefUnwindSafe, I: RefUnwindSafe,

§

impl<C, I> Send for TokenizerError<C, I>where C: Send, I: Send,

§

impl<C, I> Sync for TokenizerError<C, I>where C: Sync, I: Sync,

§

impl<C, I> Unpin for TokenizerError<C, I>where C: Unpin, I: Unpin,

§

impl<C, I> UnwindSafe for TokenizerError<C, I>where C: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.