Skip to main content

PullParser

Trait PullParser 

Source
pub trait PullParser {
    // Required method
    fn next_event(&mut self) -> Result<Event<'_, '_>, ParseError>;

    // Provided method
    fn next(&mut self) -> Option<Result<Event<'_, '_>, ParseError>> { ... }
}
Expand description

Trait for parsers that can be used in a pull-based manner.

This trait is implemented by both SliceParser and StreamParser.

Required Methods§

Source

fn next_event(&mut self) -> Result<Event<'_, '_>, ParseError>

Returns the next JSON event or an error if parsing fails. Parsing continues until EndDocument is returned or an error occurs.

Provided Methods§

Source

fn next(&mut self) -> Option<Result<Event<'_, '_>, ParseError>>

Iterator-like method that returns None when parsing is complete. This method returns None when EndDocument is reached, Some(Ok(event)) for successful events, and Some(Err(error)) for parsing errors.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§