pub struct StringTable<'a> { /* private fields */ }Expand description
Utility for working with the table of null-terminated strings after each SMBIOS structure.
Implementations§
Source§impl<'a> StringTable<'a>
impl<'a> StringTable<'a>
Sourcepub fn init(
hdr: &Header,
max_struct_len: usize,
raw_data: &'a [u8],
) -> Result<Self, Status>
pub fn init( hdr: &Header, max_struct_len: usize, raw_data: &'a [u8], ) -> Result<Self, Status>
Initializes a StringTable from a structure header and the buffer containing the
structure data (both header and trailing strings) bounded by max_struct_len.
Sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
Returns the length of the StringTable in bytes, including terminating null bytes.
Sourcepub fn get_string(&self, idx: usize) -> Result<&str, Status>
pub fn get_string(&self, idx: usize) -> Result<&str, Status>
Retrieves the string at 1-based index idx.
If idx == 0, returns Ok("<null>") indicating an unassigned string field.
Returns Err(Status::NOT_FOUND) if idx exceeds the available strings in the table.
Returns Err(Status::IO_DATA_INTEGRITY) on corrupt data or invalid UTF-8.
Sourcepub fn get_string_or_default(&self, idx: usize) -> &str
pub fn get_string_or_default(&self, idx: usize) -> &str
Convenience version of get_string that returns "<missing string>" on error,
matching C++ GetString(size_t idx).
Trait Implementations§
Source§impl<'a> Clone for StringTable<'a>
impl<'a> Clone for StringTable<'a>
Source§fn clone(&self) -> StringTable<'a>
fn clone(&self) -> StringTable<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for StringTable<'a>
Source§impl<'a> Debug for StringTable<'a>
impl<'a> Debug for StringTable<'a>
Source§impl<'a> Default for StringTable<'a>
impl<'a> Default for StringTable<'a>
Source§fn default() -> StringTable<'a>
fn default() -> StringTable<'a>
Returns the “default value” for a type. Read more
impl<'a> Eq for StringTable<'a>
Source§impl<'a> PartialEq for StringTable<'a>
impl<'a> PartialEq for StringTable<'a>
impl<'a> StructuralPartialEq for StringTable<'a>
Auto Trait Implementations§
impl<'a> Freeze for StringTable<'a>
impl<'a> RefUnwindSafe for StringTable<'a>
impl<'a> Send for StringTable<'a>
impl<'a> Sync for StringTable<'a>
impl<'a> Unpin for StringTable<'a>
impl<'a> UnsafeUnpin for StringTable<'a>
impl<'a> UnwindSafe for StringTable<'a>
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)