Struct smbioslib::UndefinedStruct [−][src]
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: Strings
The strings of the structure
Implementations
Retrieve a byte at the given offset from the structure’s data section
Retrieve a WORD at the given offset from the structure’s data section
Retrieve a Handle at the given offset from the structure’s data section
Retrieve a DWORD at the given offset from the structure’s data section
Retrieve a QWORD at the given offset from the structure’s data section
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.
Retrieve a block of bytes from the structure’s data section
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”
Down casts the current structure to its specific defined BIOS structure type
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for UndefinedStruct
impl Send for UndefinedStruct
impl Sync for UndefinedStruct
impl Unpin for UndefinedStruct
impl UnwindSafe for UndefinedStruct