ass_core/parser/streaming/mod.rs
1//! Streaming and incremental parsing for ASS scripts
2//!
3//! Provides efficient streaming parsing capabilities with true incremental
4//! processing through state machine design. Enables <5ms responsiveness
5//! for large files and editor integration.
6//!
7//! # Features
8//!
9//! - True streaming: Process chunks without loading entire file
10//! - State machine: Handle partial lines and incomplete sections
11//! - Delta tracking: Efficient change representation for editors
12//! - Memory efficiency: O(line) not O(file) memory usage
13//!
14//! # Performance
15//!
16//! - Target: <5ms per 1MB chunk processing
17//! - Memory: <1.1x input size peak usage
18//! - Incremental: <2ms for single-event edits
19//! - Supports files up to 2GB on 64-bit systems
20//!
21//! # Example
22//!
23//! ```rust
24//! use ass_core::parser::streaming::StreamingParser;
25//!
26//! let mut parser = StreamingParser::new();
27//!
28//! // Process chunks incrementally
29//! let chunk1 = b"[Script Info]\nTitle: Example\n";
30//! let deltas1 = parser.feed_chunk(chunk1)?;
31//!
32//! let chunk2 = b"[Events]\nFormat: Layer, Start, End\n";
33//! let deltas2 = parser.feed_chunk(chunk2)?;
34//!
35//! let result = parser.finish()?;
36//! # Ok::<(), Box<dyn std::error::Error>>(())
37//! ```
38
39#[cfg(not(feature = "std"))]
40extern crate alloc;
41
42mod delta;
43mod parser;
44mod processor;
45mod result;
46mod source;
47mod state;
48
49#[cfg(test)]
50mod feed_tests;
51#[cfg(test)]
52mod parser_tests;
53#[cfg(test)]
54mod result_tests;
55
56// Re-export public API
57pub use delta::{DeltaBatch, ParseDelta};
58pub use parser::StreamingParser;
59pub use processor::LineProcessor;
60pub use result::StreamingResult;
61pub use source::build_modified_source;
62pub use state::{ParserState, SectionKind, StreamingContext};