#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum TokenContext {
#[default]
Document,
SectionHeader,
FieldValue,
StyleOverride,
DrawingCommands,
UuEncodedData,
}
impl TokenContext {
#[must_use]
pub const fn allows_whitespace_skipping(self) -> bool {
!matches!(self, Self::FieldValue | Self::UuEncodedData)
}
#[must_use]
pub const fn is_delimited_block(self) -> bool {
matches!(self, Self::SectionHeader | Self::StyleOverride)
}
#[must_use]
pub const fn closing_delimiter(self) -> Option<char> {
match self {
Self::SectionHeader => Some(']'),
Self::StyleOverride => Some('}'),
_ => None,
}
}
#[must_use]
pub const fn enter_field_value(self) -> Self {
match self {
Self::Document => Self::FieldValue,
other => other,
}
}
#[must_use]
pub const fn reset_to_document(self) -> Self {
Self::Document
}
}