Trait ParseError

pub trait ParseError<I>: Sized {
    // Required methods
    fn from_error_kind(input: I, kind: ErrorKind) -> Self;
    fn append(input: I, kind: ErrorKind, other: Self) -> Self;

    // Provided methods
    fn from_char(input: I, _: char) -> Self { ... }
    fn or(self, other: Self) -> Self { ... }
}
Expand description

This trait must be implemented by the error type of a nom parser.

There are already implementations of it for (Input, ErrorKind) and VerboseError<Input>.

It provides methods to create an error from some combinators, and combine existing errors in combinators like alt.

Required Methods§

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

Creates an error from the input position and an ErrorKind

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

Provided Methods§

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

Creates an error from an input position and an expected character

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<I> ParseError<I> for (I, ErrorKind)

§

fn from_error_kind(input: I, kind: ErrorKind) -> (I, ErrorKind)

§

fn append(_: I, _: ErrorKind, other: (I, ErrorKind)) -> (I, ErrorKind)

§

impl<I> ParseError<I> for ()

§

fn from_error_kind(_: I, _: ErrorKind)

§

fn append(_: I, _: ErrorKind, _: ())

§

impl<I> ParseError<I> for X509Error

§

fn from_error_kind(_input: I, kind: ErrorKind) -> X509Error

§

fn append(_input: I, kind: ErrorKind, _other: X509Error) -> X509Error

Implementors§

§

impl<'a> ParseError<&'a [u8]> for rama::crypto::dep::x509_parser::prelude::asn1_rs::Error

§

impl<I> ParseError<I> for rama::crypto::dep::x509_parser::error::X509Error

§

impl<I> ParseError<I> for rama::crypto::dep::x509_parser::prelude::asn1_rs::nom::error::Error<I>

§

impl<I> ParseError<I> for VerboseError<I>