Trait InnerState

Source
pub trait InnerState: Default {
    type Output: Sized;

    // Required method
    fn parse_inner_finish(self) -> Result<Self::Output>;

    // Provided methods
    fn parse_inner_node<P: ElementParser>(
        &mut self,
        tag: &str,
        parser: P,
    ) -> Result<InnerParseResult<P>> { ... }
    fn parse_inner_text<'t>(
        &mut self,
        text: Cow<'t, str>,
    ) -> Result<InnerParseResult<Cow<'t, str>>> { ... }
}
Expand description

State to parse multiple elements (on the same level)

Required Associated Types§

Source

type Output: Sized

Once fully parsed this is the resulting output type.

Required Methods§

Source

fn parse_inner_finish(self) -> Result<Self::Output>

Finish parsing.

Provided Methods§

Source

fn parse_inner_node<P: ElementParser>( &mut self, tag: &str, parser: P, ) -> Result<InnerParseResult<P>>

Try parsing an element with the given tag

Should not fail if it doesn’t recognize the tag; instead it needs to return the parser.

Source

fn parse_inner_text<'t>( &mut self, text: Cow<'t, str>, ) -> Result<InnerParseResult<Cow<'t, str>>>

Try parsing inner text

Should not fail if it doesn’t take text (but may fail if it does but can’t parse it).

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§

Source§

impl InnerState for Cow<'_, str>

Source§

type Output = Cow<'_, str>

Source§

fn parse_inner_text<'t>( &mut self, text: Cow<'t, str>, ) -> Result<InnerParseResult<Cow<'t, str>>>

Source§

fn parse_inner_finish(self) -> Result<Self::Output>

Source§

impl InnerState for String

Using String as InnerState to collect all inner text in it (including whitespace in input)

Source§

type Output = String

Source§

fn parse_inner_text<'t>( &mut self, text: Cow<'t, str>, ) -> Result<InnerParseResult<Cow<'t, str>>>

Source§

fn parse_inner_finish(self) -> Result<Self::Output>

Implementors§