StreamingParser

Struct StreamingParser 

Source
pub struct StreamingParser<'a> {
Show 13 fields scanner: Option<BasicScanner>, zero_scanner: Option<ZeroScanner<'a>>, config: StreamingConfig, event_buffer: VecDeque<Event>, state: ParserState, state_stack: Vec<ParserState>, position: Position, depth: usize, pending_anchor: Option<String>, pending_tag: Option<String>, stats: Option<StreamingStats>, start_time: Instant, stream_ended: bool,
}
Expand description

Streaming YAML parser that processes events on demand

Fields§

§scanner: Option<BasicScanner>

Traditional scanner for compatibility

§zero_scanner: Option<ZeroScanner<'a>>

Zero-copy scanner for optimized parsing

§config: StreamingConfig

Configuration

§event_buffer: VecDeque<Event>

Event buffer for batched processing

§state: ParserState

Current parser state

§state_stack: Vec<ParserState>

State stack for nested structures

§position: Position

Current position

§depth: usize

Current nesting depth

§pending_anchor: Option<String>

Pending anchor for next node

§pending_tag: Option<String>

Pending tag for next node

§stats: Option<StreamingStats>

Statistics (if enabled)

§start_time: Instant

Start time for performance measurement

§stream_ended: bool

Whether the stream has ended

Implementations§

Source§

impl<'a> StreamingParser<'a>

Source

pub fn new(input: String, config: StreamingConfig) -> StreamingParser<'static>

Create a new streaming parser with traditional scanner

Source

pub fn new_zero_copy(input: &'a str, config: StreamingConfig) -> Self

Create a new streaming parser with zero-copy scanner

Source

pub fn next_batch(&mut self) -> Result<Vec<Event>>

Get the next batch of events

Source

fn next_event_internal(&mut self) -> Result<Option<Event>>

Get the next event from buffer or generate a new one

Source

fn generate_events(&mut self) -> Result<()>

Generate events by processing tokens

Source

fn generate_events_zero_copy(&mut self) -> Result<()>

Generate events using zero-copy scanner

Source

fn generate_events_traditional(&mut self) -> Result<()>

Generate events using traditional scanner

Source

fn is_document_start_candidate_simple(&self) -> bool

Check if this position could be document start (—) - simplified version

Source

fn is_document_end_candidate_simple(&self) -> bool

Check if this position could be document end (…) - simplified version

Source

fn is_value_indicator_simple(&self) -> bool

Check if colon is a value indicator - simplified version

Source

fn handle_document_start(&mut self)

Handle document start

Source

fn handle_document_end(&mut self)

Handle document end

Source

fn handle_flow_sequence_start(&mut self)

Handle flow sequence start

Source

fn handle_flow_sequence_end(&mut self)

Handle flow sequence end

Source

fn handle_flow_mapping_start(&mut self)

Handle flow mapping start

Source

fn handle_flow_mapping_end(&mut self)

Handle flow mapping end

Source

fn handle_value_indicator(&mut self)

Handle value indicator (:)

Source

fn handle_zero_copy_scalar(&mut self, token: ZeroToken<'_>) -> Result<()>

Handle zero-copy scalar token

Source

fn skip_comment_simple(&mut self)

Skip comment line - simplified version

Source

fn process_token(&mut self, token: Token) -> Result<()>

Process a token from traditional scanner

Source

fn push_state(&mut self, new_state: ParserState)

Push a new state onto the stack

Source

fn pop_state(&mut self)

Pop state from the stack

Source

fn update_stats_for_event(&mut self, _event: &Event)

Update statistics for processed event

Source

pub fn get_stats(&mut self) -> Option<StreamingStats>

Get current parsing statistics

Source

pub fn has_more_events(&self) -> bool

Check if more events are available

Source

pub fn buffer_size(&self) -> usize

Get the current buffer size

Trait Implementations§

Source§

impl<'a> Parser for StreamingParser<'a>

Source§

fn check_event(&self) -> bool

Check if there are more events available
Source§

fn peek_event(&self) -> Result<Option<&Event>>

Peek at the next event without consuming it
Source§

fn get_event(&mut self) -> Result<Option<Event>>

Get the next event, consuming it
Source§

fn reset(&mut self)

Reset the parser state
Source§

fn position(&self) -> Position

Get the current position in the input

Auto Trait Implementations§

§

impl<'a> Freeze for StreamingParser<'a>

§

impl<'a> RefUnwindSafe for StreamingParser<'a>

§

impl<'a> Send for StreamingParser<'a>

§

impl<'a> Sync for StreamingParser<'a>

§

impl<'a> Unpin for StreamingParser<'a>

§

impl<'a> UnwindSafe for StreamingParser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.