Skip to main content

StringTable

Struct StringTable 

Source
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>

Source

pub const fn empty() -> Self

Creates an empty StringTable.

Source

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.

Source

pub fn length(&self) -> usize

Returns the length of the StringTable in bytes, including terminating null bytes.

Source

pub fn is_empty(&self) -> bool

Returns true if the string table contains no string entries.

Source

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.

Source

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).

Source

pub fn dump<W: Write>(&self, writer: &mut W) -> Result

Dumps the string table contents to the provided writer.

Trait Implementations§

Source§

impl<'a> Clone for StringTable<'a>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for StringTable<'a>

Source§

impl<'a> Debug for StringTable<'a>

Source§

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

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

impl<'a> Default for StringTable<'a>

Source§

fn default() -> StringTable<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> Eq for StringTable<'a>

Source§

impl<'a> PartialEq for StringTable<'a>

Source§

fn eq(&self, other: &StringTable<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

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

Inequality operator !=. Read more
Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.