pub struct StringTable { /* private fields */ }Expand description
A string table mapping u8 indices to UTF-8 names
Implementations§
Source§impl StringTable
impl StringTable
Sourcepub fn add(&mut self, name: &str) -> FafbResult<u8>
pub fn add(&mut self, name: &str) -> FafbResult<u8>
Add a name to the table. Returns the index. If the name already exists, returns the existing index (dedup).
Sourcepub fn get(&self, index: u8) -> FafbResult<&str>
pub fn get(&self, index: u8) -> FafbResult<&str>
Get a name by index
Sourcepub fn to_bytes(&self) -> FafbResult<Vec<u8>>
pub fn to_bytes(&self) -> FafbResult<Vec<u8>>
Serialize to bytes
Format: [u16 count] [u16 len₀][utf8₀] [u16 len₁][utf8₁] ...
Sourcepub fn from_bytes(data: &[u8]) -> FafbResult<Self>
pub fn from_bytes(data: &[u8]) -> FafbResult<Self>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for StringTable
impl Clone for StringTable
Source§fn clone(&self) -> StringTable
fn clone(&self) -> StringTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringTable
impl Debug for StringTable
Source§impl Default for StringTable
impl Default for StringTable
Source§fn default() -> StringTable
fn default() -> StringTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StringTable
impl RefUnwindSafe for StringTable
impl Send for StringTable
impl Sync for StringTable
impl Unpin for StringTable
impl UnsafeUnpin for StringTable
impl UnwindSafe for StringTable
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