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>
impl<'a> EventsParser<'a>
Sourcepub fn parse_event_line(
line: &'a str,
format: &[&'a str],
line_number: u32,
) -> Result<Event<'a>, ParseError>
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 lineline_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
Sourcepub fn new(source: &'a str, start_position: usize, start_line: usize) -> Self
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 parsestart_position- Starting byte position in sourcestart_line- Starting line number for error reporting
Sourcepub fn with_format(
source: &'a str,
format: &[&'a str],
start_position: usize,
start_line: u32,
) -> Self
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
Sourcepub fn parse(self) -> ParseResult<SectionParseResult<'a>>
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.
Sourcepub fn issues(self) -> Vec<ParseIssue>
pub fn issues(self) -> Vec<ParseIssue>
Get accumulated parse issues