pub struct UndefinedStruct {
    pub header: Header,
    pub fields: Vec<u8>,
    pub strings: SMBiosStringSet,
}
Expand description

Embodies the three basic parts of an SMBIOS structure

Every SMBIOS structure contains three distinct sections:

  • A header
  • A formatted structure of fields (offsets and widths)
  • String data

A consumer of BIOS data ultimately wants to work with a DefinedStruct. UndefinedStruct provides a set of fields and functions that enables downcasting to a DefinedStruct. Further, the OEM is allowed to define their own structures and in such cases working with UndefinedStruct is necessary. Therefore, UndefinedStruct is public for the case of OEM, as well as when working with structures that are defined in an SMBIOS standard newer than the one this library currently supports.

Fields§

§header: Header

The Header of the structure

§fields: Vec<u8>

The raw data for the header and fields

fields is used by the get_field_*() functions. fields does not include strings; therefore, preventing accidentally retrieving data from the strings area. This avoids a need to check header.length() during field retrieval.

Note: A better design is for this to only hold the fields, however, that will shift field offsets given in code by 4 (the header size). The SMBIOS specification gives offsets relative to the start of the header, and therefore maintaining this library code is easier to keep the header.

An alternative would be to make the get_field_*() functions adjust for the header offset though this adds a small cost to every field retrieval in comparison to just keeping an extra 4 bytes for every structure.

§strings: SMBiosStringSet

The strings of the structure

Implementations§

source§

impl<'a> UndefinedStruct

source

pub fn new(raw: &Vec<u8>) -> Self

Creates a structure instance of the given byte array slice

source

pub fn get_field_byte(&self, offset: usize) -> Option<u8>

Retrieve a byte at the given offset from the structure’s data section

source

pub fn get_field_word(&self, offset: usize) -> Option<u16>

Retrieve a WORD at the given offset from the structure’s data section

source

pub fn get_field_handle(&self, offset: usize) -> Option<Handle>

Retrieve a Handle at the given offset from the structure’s data section

source

pub fn get_field_dword(&self, offset: usize) -> Option<u32>

Retrieve a DWORD at the given offset from the structure’s data section

source

pub fn get_field_qword(&self, offset: usize) -> Option<u64>

Retrieve a QWORD at the given offset from the structure’s data section

source

pub fn get_field_string(&self, offset: usize) -> SMBiosString

Retrieve a String of the given offset

Retrieval of strings is a two part operation. The given offset contains a byte whose value is a 1 based index into the strings section. The string is thus retrieved from the strings section based on the byte value at the given offset.

source

pub fn get_field_data( &self, start_index: usize, end_index: usize ) -> Option<&[u8]>

Retrieve a block of bytes from the structure’s data section

source

pub fn as_type<T: SMBiosStruct<'a>>(&'a self) -> Option<T>

Cast to a given structure

When this library does not contain a DefinedStruct variant matching the SMBiosStruct::STRUCT_TYPE, this function affords a cast to the given type. Such would be the case with OEM structure type T (which implements the SMBiosStruct trait).

TODO: This should panic (not be Option) when the STRUCT_TYPE does not match because this would be a logic error in code, not a runtime error.

Make this a “try_into”

source

pub fn defined_struct(&self) -> DefinedStruct<'_>

Down casts the current structure to its specific defined BIOS structure type

Trait Implementations§

source§

impl Debug for UndefinedStruct

source§

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

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

impl Default for UndefinedStruct

source§

fn default() -> Self

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

impl<'a> From<&'a UndefinedStruct> for DefinedStruct<'a>

source§

fn from(undefined_struct: &'a UndefinedStruct) -> Self

Converts to this type from the input type.
source§

impl<'a> FromIterator<&'a UndefinedStruct> for DefinedStructTable<'a>

source§

fn from_iter<I: IntoIterator<Item = &'a UndefinedStruct>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl Serialize for UndefinedStruct

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.