pub trait StreamingParser: Iterator<Item = AnyResult<Subtitle>> {
// Provided methods
fn collect_all(&mut self) -> AnyResult<Vec<Subtitle>> { ... }
fn count_remaining(&mut self) -> usize { ... }
}Expand description
Trait for streaming subtitle parsers.
Provides a unified interface for incremental parsing of subtitle files, useful for large files or memory-constrained environments.
§Example
use subtitler::model::StreamingParser;
let content = "1\n00:00:01,000 --> 00:00:03,500\nHello\n\n";
let mut parser = subtitler::srt::parse_stream(content);
while let Some(result) = parser.next() {
let subtitle = result?;
println!("{:?}", subtitle);
}Provided Methods§
Sourcefn collect_all(&mut self) -> AnyResult<Vec<Subtitle>>
fn collect_all(&mut self) -> AnyResult<Vec<Subtitle>>
Parse all remaining subtitles and return as a vector.
Returns an error if any subtitle fails to parse.
Sourcefn count_remaining(&mut self) -> usize
fn count_remaining(&mut self) -> usize
Count remaining subtitles without collecting them.
This consumes the iterator.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".