ass_core/parser/streaming/state/
context.rs1use alloc::string::String;
7
8use super::SectionKind;
9
10#[derive(Debug, Clone)]
15pub struct StreamingContext {
16 pub line_number: usize,
18 pub current_section: Option<SectionKind>,
20 pub events_format: Option<String>,
22 pub styles_format: Option<String>,
24}
25
26impl StreamingContext {
27 #[must_use]
29 pub const fn new() -> Self {
30 Self {
31 line_number: 0,
32 current_section: None,
33 events_format: None,
34 styles_format: None,
35 }
36 }
37
38 pub fn next_line(&mut self) {
40 self.line_number += 1;
41 }
42
43 pub fn enter_section(&mut self, kind: SectionKind) {
45 self.current_section = Some(kind);
46 }
47
48 pub fn exit_section(&mut self) {
50 self.current_section = None;
51 }
52
53 pub fn set_events_format(&mut self, format: String) {
55 self.events_format = Some(format);
56 }
57
58 pub fn set_styles_format(&mut self, format: String) {
60 self.styles_format = Some(format);
61 }
62
63 pub fn reset(&mut self) {
65 self.line_number = 0;
66 self.current_section = None;
67 self.events_format = None;
68 self.styles_format = None;
69 }
70}
71
72impl Default for StreamingContext {
73 fn default() -> Self {
74 Self::new()
75 }
76}