pub struct StringTable(/* private fields */);Expand description
A table that stores NUL-terminated strings.
Always starts and ends with a NUL byte.
Implementations§
Source§impl StringTable
impl StringTable
Sourcepub fn insert(&mut self, string: &CStr) -> usize
pub fn insert(&mut self, string: &CStr) -> usize
Insert new string into the table.
Does nothing if the string is already in the table.
Returns the offset at which you can find the string.
Sourcepub fn get_offset(&self, string: &CStr) -> Option<usize>
pub fn get_offset(&self, string: &CStr) -> Option<usize>
Get the offset of the string in the table.
Returns None if the string isn’t present in the table.
Sourcepub fn get_string(&self, offset: usize) -> Option<&CStr>
pub fn get_string(&self, offset: usize) -> Option<&CStr>
Get a reference to a string at offset.
Returns None if the offset is out-of-bounds.
Sourcepub fn into_inner(self) -> Vec<u8> ⓘ
pub fn into_inner(self) -> Vec<u8> ⓘ
Get the underlying vector.
Trait Implementations§
Source§impl AsRef<[u8]> for StringTable
impl AsRef<[u8]> for StringTable
Source§impl BlockRead for StringTable
impl BlockRead for StringTable
Source§impl Default for StringTable
impl Default for StringTable
Source§impl<T: AsRef<CStr>> FromIterator<T> for StringTable
impl<T: AsRef<CStr>> FromIterator<T> for StringTable
Source§fn from_iter<I>(items: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(items: I) -> Selfwhere
I: IntoIterator<Item = T>,
Creates a value from an iterator. 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 UnwindSafe for StringTable
Blanket Implementations§
Source§impl<T> BlockWrite for T
impl<T> BlockWrite for T
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