use alloc::string::String;
use super::SectionKind;
#[derive(Debug, Clone)]
pub struct StreamingContext {
pub line_number: usize,
pub current_section: Option<SectionKind>,
pub events_format: Option<String>,
pub styles_format: Option<String>,
}
impl StreamingContext {
#[must_use]
pub const fn new() -> Self {
Self {
line_number: 0,
current_section: None,
events_format: None,
styles_format: None,
}
}
pub fn next_line(&mut self) {
self.line_number += 1;
}
pub fn enter_section(&mut self, kind: SectionKind) {
self.current_section = Some(kind);
}
pub fn exit_section(&mut self) {
self.current_section = None;
}
pub fn set_events_format(&mut self, format: String) {
self.events_format = Some(format);
}
pub fn set_styles_format(&mut self, format: String) {
self.styles_format = Some(format);
}
pub fn reset(&mut self) {
self.line_number = 0;
self.current_section = None;
self.events_format = None;
self.styles_format = None;
}
}
impl Default for StreamingContext {
fn default() -> Self {
Self::new()
}
}