Struct smbioslib::UndefinedStruct[][src]

pub struct UndefinedStruct {
    pub header: Header,
    pub fields: Vec<u8>,
    pub strings: Strings,
}

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: Strings

The strings of the structure

Implementations

impl<'a> UndefinedStruct[src]

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

Creates a structure instance of the given byte array slice

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

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

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

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

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

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

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

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

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

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

pub fn get_field_string(&self, offset: usize) -> Option<String>[src]

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.

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

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

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

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”

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

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

Trait Implementations

impl Debug for UndefinedStruct[src]

impl Default for UndefinedStruct[src]

impl<'a> From<&'a UndefinedStruct> for DefinedStruct<'a>[src]

impl<'a> FromIterator<&'a UndefinedStruct> for DefinedStructTable<'a>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.