Enum Symbol

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn into_char(self) -> Result<char, BadSymbol>

Converts the symbol into a char.

Source

pub fn into_digit(self, base: u32) -> Result<u32, SyntaxError>

Converts the symbol representing a digit into its integer value.

Source

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.

Source

pub fn is_word_char(self) -> bool

Returns whether the symbol can occur as part of a word.

Trait Implementations§

Source§

impl Clone for Symbol

Source§

fn clone(&self) -> Symbol

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Symbol

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<char> for Symbol

Source§

fn from(ch: char) -> Symbol

Converts to this type from the input type.
Source§

impl PartialEq for Symbol

Source§

fn eq(&self, other: &Symbol) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Symbol

Source§

impl Eq for Symbol

Source§

impl StructuralPartialEq for Symbol

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.