Skip to main content

TrySpannedEventReceiver

Trait TrySpannedEventReceiver 

Source
pub trait TrySpannedEventReceiver<'input> {
    type Error;

    // Required method
    fn on_event(
        &mut self,
        ev: Event<'input>,
        span: Span,
    ) -> Result<(), Self::Error>;
}
Expand description

Trait to be implemented for fallible event handling with source spans.

This is the fallible counterpart to SpannedEventReceiver. Use it with Parser::try_load when event handling may need to stop parsing by returning an application error.

Required Associated Types§

Source

type Error

Error returned by this receiver.

Required Methods§

Source

fn on_event(&mut self, ev: Event<'input>, span: Span) -> Result<(), Self::Error>

Handler called for each event that occurs.

Returning an error stops Parser::try_load immediately.

§Errors

Returns Self::Error when the receiver wants to stop parsing.

Implementors§

Source§

impl<'input, R: TryEventReceiver<'input>> TrySpannedEventReceiver<'input> for R

Source§

type Error = <R as TryEventReceiver<'input>>::Error