pub trait Parser<Input> {
    type Output;
    type Error: ParseError<Input>;
    // Required method
    fn process<OM: OutputMode>(
        &mut self,
        input: Input,
    ) -> PResult<OM, Input, Self::Output, Self::Error>;
    // Provided methods
    fn parse(
        &mut self,
        input: Input,
    ) -> IResult<Input, Self::Output, Self::Error> { ... }
    fn parse_complete(
        &mut self,
        input: Input,
    ) -> IResult<Input, Self::Output, Self::Error> { ... }
    fn map<G, O2>(self, g: G) -> Map<Self, G>
       where G: FnMut(Self::Output) -> O2,
             Self: Sized { ... }
    fn map_res<G, O2, E2>(self, g: G) -> MapRes<Self, G>
       where G: FnMut(Self::Output) -> Result<O2, E2>,
             Self::Error: FromExternalError<Input, E2>,
             Self: Sized { ... }
    fn map_opt<G, O2>(self, g: G) -> MapOpt<Self, G>
       where G: FnMut(Self::Output) -> Option<O2>,
             Self: Sized { ... }
    fn flat_map<G, H>(self, g: G) -> FlatMap<Self, G>
       where G: FnMut(Self::Output) -> H,
             H: Parser<Input, Error = Self::Error>,
             Self: Sized { ... }
    fn and_then<G>(self, g: G) -> AndThen<Self, G>
       where G: Parser<Self::Output, Error = Self::Error>,
             Self: Sized { ... }
    fn and<G, O2>(self, g: G) -> And<Self, G>
       where G: Parser<Input, Output = O2, Error = Self::Error>,
             Self: Sized { ... }
    fn or<G>(self, g: G) -> Or<Self, G>
       where G: Parser<Input, Output = Self::Output, Error = Self::Error>,
             Self: Sized { ... }
    fn into<O2: From<Self::Output>, E2: From<Self::Error>>(
        self,
    ) -> Into<Self, O2, E2>
       where Self: Sized { ... }
}Expand description
All nom parsers implement this trait
Required Associated Types§
Sourcetype Error: ParseError<Input>
 
type Error: ParseError<Input>
Error type of this parser
Required Methods§
Provided Methods§
Sourcefn parse(&mut self, input: Input) -> IResult<Input, Self::Output, Self::Error>
 
fn parse(&mut self, input: Input) -> IResult<Input, Self::Output, Self::Error>
A parser takes in input type, and returns a Result containing
either the remaining input and the output value, or an error
Sourcefn parse_complete(
    &mut self,
    input: Input,
) -> IResult<Input, Self::Output, Self::Error>
 
fn parse_complete( &mut self, input: Input, ) -> IResult<Input, Self::Output, Self::Error>
A parser takes in input type, and returns a Result containing
either the remaining input and the output value, or an error
Sourcefn map_res<G, O2, E2>(self, g: G) -> MapRes<Self, G>
 
fn map_res<G, O2, E2>(self, g: G) -> MapRes<Self, G>
Applies a function returning a Result over the result of a parser.
Sourcefn map_opt<G, O2>(self, g: G) -> MapOpt<Self, G>
 
fn map_opt<G, O2>(self, g: G) -> MapOpt<Self, G>
Applies a function returning an Option over the result of a parser.
Sourcefn flat_map<G, H>(self, g: G) -> FlatMap<Self, G>
 
fn flat_map<G, H>(self, g: G) -> FlatMap<Self, G>
Creates a second parser from the output of the first one, then apply over the rest of the input
Sourcefn and_then<G>(self, g: G) -> AndThen<Self, G>
 
fn and_then<G>(self, g: G) -> AndThen<Self, G>
Applies a second parser over the output of the first one
Sourcefn and<G, O2>(self, g: G) -> And<Self, G>
 
fn and<G, O2>(self, g: G) -> And<Self, G>
Applies a second parser after the first one, return their results as a tuple
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.