pub struct TokenTable<'a> { /* private fields */ }Expand description
The token dictionaries a frame’s tags index into.
Implementations§
Source§impl<'a> TokenTable<'a>
impl<'a> TokenTable<'a>
Sourcepub const fn new(
single_byte: &'a [&'a str],
dictionaries: &'a [&'a [&'a str]],
) -> Self
pub const fn new( single_byte: &'a [&'a str], dictionaries: &'a [&'a [&'a str]], ) -> Self
Build a table from a single-byte list and the double-byte dictionaries.
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
An empty table. Every token lookup fails, which is what a host wants while it is still deciding which spec build to load.
Sourcepub fn single_byte(&self, tag: u8) -> Option<&'a str>
pub fn single_byte(&self, tag: u8) -> Option<&'a str>
The single-byte token for tag.
The tag byte is the index. Slot 0 is never a real token — that byte
means LIST_EMPTY on the wire — so a table carries a placeholder there
rather than shifting everything by one. Getting this off by one silently
resolves every token to its neighbour, so it is pinned by a test against
the engine’s own table.
Sourcepub fn dictionary(&self, dictionary: u8, index: u8) -> Option<&'a str>
pub fn dictionary(&self, dictionary: u8, index: u8) -> Option<&'a str>
The token at index of dictionary dictionary.
Sourcepub const fn single_byte_len(&self) -> usize
pub const fn single_byte_len(&self) -> usize
How many single-byte tokens the table holds.
Sourcepub const fn dictionary_count(&self) -> usize
pub const fn dictionary_count(&self) -> usize
How many double-byte dictionaries the table holds.
Trait Implementations§
Source§impl<'a> Clone for TokenTable<'a>
impl<'a> Clone for TokenTable<'a>
impl<'a> Copy for TokenTable<'a>
Source§impl<'a> Debug for TokenTable<'a>
impl<'a> Debug for TokenTable<'a>
Source§impl Default for TokenTable<'_>
impl Default for TokenTable<'_>
impl<'a> Eq for TokenTable<'a>
Source§impl<'a> PartialEq for TokenTable<'a>
impl<'a> PartialEq for TokenTable<'a>
impl<'a> StructuralPartialEq for TokenTable<'a>
Auto Trait Implementations§
impl<'a> Freeze for TokenTable<'a>
impl<'a> RefUnwindSafe for TokenTable<'a>
impl<'a> Send for TokenTable<'a>
impl<'a> Sync for TokenTable<'a>
impl<'a> Unpin for TokenTable<'a>
impl<'a> UnsafeUnpin for TokenTable<'a>
impl<'a> UnwindSafe for TokenTable<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more