pub enum Symbol {
Char(char),
SimpleEscape(char),
DecimalEscape(u8),
}Expand description
The master file representation of a single character.
Variants§
Char(char)
An unescaped Unicode character.
SimpleEscape(char)
An escape character by simply being backslashed.
DecimalEscape(u8)
An escaped character using the decimal escape sequence.
Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn from_chars<C>(chars: C) -> Result<Option<Self>, SymbolError>where
C: IntoIterator<Item = char>,
pub fn from_chars<C>(chars: C) -> Result<Option<Self>, SymbolError>where
C: IntoIterator<Item = char>,
Reads a symbol from a character source.
Returns the next symbol in the source, Ok(None) if the source has
been exhausted, or an error if there wasn’t a valid symbol.
Sourcepub fn from_byte(ch: u8) -> Self
pub fn from_byte(ch: u8) -> Self
Provides the best symbol for a byte.
The function will use simple escape sequences for spaces, quotes, backslashs, and semicolons. It will leave all other printable ASCII characters unescaped and decimal escape all remaining byte value.
Sourcepub fn into_byte(self) -> Result<u8, BadSymbol>
pub fn into_byte(self) -> Result<u8, BadSymbol>
Converts the symbol into a byte if it represents one.
Both domain names and character strings operate on bytes instead of (Unicode) characters. These bytes can be represented by printable ASCII characters (that is, U+0020 to U+007E), both plain or through a simple escape, or by a decimal escape.
This method returns such a byte or an error otherwise. Note that it will succeed for an ASCII space character U+0020 which may be used as a word separator in some cases.
Sourcepub fn into_digit(self, base: u32) -> Result<u32, SyntaxError>
pub fn into_digit(self, base: u32) -> Result<u32, SyntaxError>
Converts the symbol representing a digit into its integer value.
Sourcepub fn push_to_buf(self, buf: &mut BytesMut) -> Result<(), BadSymbol>
pub fn push_to_buf(self, buf: &mut BytesMut) -> Result<(), BadSymbol>
Pushes a symbol that is a byte to the end of a byte buffer.
If the symbol is a byte as per the rules described in into_byte,
it will be pushed to the end of buf, reserving additional space
if there isn’t enough space remaining.
Sourcepub fn is_word_char(self) -> bool
pub fn is_word_char(self) -> bool
Returns whether the symbol can occur as part of a word.