Struct EventsParser

Source
pub struct EventsParser<'a> { /* private fields */ }
Expand description

Parser for [Events] section content

Parses format definitions and event entries from the events section. Uses format mapping to handle different field orderings and event types.

§Performance

  • Time complexity: O(n * m) for n events and m fields per event
  • Memory: Zero allocations via lifetime-generic spans
  • Target: <2ms for typical event sections with 1000 events

Implementations§

Source§

impl<'a> EventsParser<'a>

Source

pub fn parse_event_line( line: &'a str, format: &[&'a str], line_number: u32, ) -> Result<Event<'a>, ParseError>

Parse a single event line (make existing internal method public)

Parses a single event line using the provided format specification. This method is exposed for incremental parsing support.

§Arguments
  • line - The event line to parse (e.g., “Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,Text”)
  • format - The format fields from the Format line
  • line_number - The line number for error reporting
§Returns

Parsed Event or error if the line is malformed

§Errors

Returns ParseError::InvalidEventType if the line doesn’t start with a valid event type Returns ParseError::InsufficientFields if the line has fewer fields than expected by format

Source

pub fn new(source: &'a str, start_position: usize, start_line: usize) -> Self

Create new events parser for source text

§Arguments
  • source - Source text to parse
  • start_position - Starting byte position in source
  • start_line - Starting line number for error reporting
Source

pub fn with_format( source: &'a str, format: &[&'a str], start_position: usize, start_line: u32, ) -> Self

Create a new parser with a pre-known format for incremental parsing

Source

pub fn parse(self) -> ParseResult<SectionParseResult<'a>>

Parse events section content

Returns the parsed section and any issues encountered during parsing. Handles Format line parsing and event entry validation.

§Returns

Tuple of (parsed_section, format_fields, parse_issues, final_position, final_line)

§Errors

Returns an error if the events section contains malformed format lines or other unrecoverable syntax errors.

Source

pub fn issues(self) -> Vec<ParseIssue>

Get accumulated parse issues

Source

pub const fn format(&self) -> Option<&Vec<&'a str>>

Get format specification

Auto Trait Implementations§

§

impl<'a> Freeze for EventsParser<'a>

§

impl<'a> RefUnwindSafe for EventsParser<'a>

§

impl<'a> Send for EventsParser<'a>

§

impl<'a> Sync for EventsParser<'a>

§

impl<'a> Unpin for EventsParser<'a>

§

impl<'a> UnwindSafe for EventsParser<'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.