#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NonAsciiCodeByte {
byte: u8,
}
impl NonAsciiCodeByte {
pub(crate) const fn parse(byte: u8) -> Option<Self> {
if byte.is_ascii() {
None
} else {
Some(Self { byte })
}
}
#[must_use]
pub const fn get(self) -> u8 {
self.byte
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NonPrintableCodeByte {
byte: u8,
}
impl NonPrintableCodeByte {
pub(crate) const fn parse(byte: u8) -> Option<Self> {
if byte.is_ascii() && !byte.is_ascii_graphic() {
Some(Self { byte })
} else {
None
}
}
#[must_use]
pub const fn get(self) -> u8 {
self.byte
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NonAsciiInputByte {
byte: u8,
}
impl NonAsciiInputByte {
pub(crate) const fn parse(byte: u8) -> Option<Self> {
if byte.is_ascii() {
None
} else {
Some(Self { byte })
}
}
#[must_use]
pub const fn get(self) -> u8 {
self.byte
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ReservedSyntaxByte {
Equals,
Comment,
OpenParen,
CloseParen,
}
impl ReservedSyntaxByte {
pub(crate) const fn parse(byte: u8) -> Option<Self> {
match byte {
b'=' => Some(Self::Equals),
b'#' => Some(Self::Comment),
b'(' => Some(Self::OpenParen),
b')' => Some(Self::CloseParen),
_ => None,
}
}
#[must_use]
pub const fn get(self) -> u8 {
match self {
Self::Equals => b'=',
Self::Comment => b'#',
Self::OpenParen => b'(',
Self::CloseParen => b')',
}
}
}