Trait Parser

Source
pub trait Parser {
    type Rule: RuleType;
    type Parser: PestParser<Self::Rule>;

    // Provided methods
    fn parse<'i>(
        rule: Self::Rule,
        input_str: &'i str,
    ) -> Result<Nodes<'i, Self::Rule, ()>, Error<Self::Rule>> { ... }
    fn parse_with_userdata<'i, D>(
        rule: Self::Rule,
        input_str: &'i str,
        user_data: D,
    ) -> Result<Nodes<'i, Self::Rule, D>, Error<Self::Rule>> { ... }
}
Expand description

A trait that provides methods to parse strings. Do not implement manually; instead use the parser macro provided by this crate.

Required Associated Types§

Provided Methods§

Source

fn parse<'i>( rule: Self::Rule, input_str: &'i str, ) -> Result<Nodes<'i, Self::Rule, ()>, Error<Self::Rule>>

Parses a &str starting from rule

Source

fn parse_with_userdata<'i, D>( rule: Self::Rule, input_str: &'i str, user_data: D, ) -> Result<Nodes<'i, Self::Rule, D>, Error<Self::Rule>>

Parses a &str starting from rule, carrying user_data through the parser methods.

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.

Implementors§