Struct uefi::proto::device_path::DevicePathNode
source · #[repr(C, packed(1))]pub struct DevicePathNode { /* private fields */ }
Expand description
A single node within a DevicePath
.
Each node starts with a DevicePathHeader
. The rest of the data
in the node depends on the type of node. You can “cast” a node to a specific
one like this:
use uefi::proto::device_path::DevicePath;
use uefi::proto::device_path::media::FilePath;
let image_device_path: &DevicePath = unsafe { DevicePath::from_ffi_ptr(0x1337 as *const _) };
let file_path = image_device_path
.node_iter()
.find_map(|node| {
let node: &FilePath = node.try_into().ok()?;
let path = node.path_name().to_cstring16().ok()?;
Some(path.to_string().to_uppercase())
});
More types are available in uefi::proto::device_path
. Builder types
can be found in uefi::proto::device_path::build
See the module-level documentation for more details.
Implementations§
source§impl DevicePathNode
impl DevicePathNode
sourcepub unsafe fn from_ffi_ptr<'a>(ptr: *const FfiDevicePath) -> &'a DevicePathNode
pub unsafe fn from_ffi_ptr<'a>(ptr: *const FfiDevicePath) -> &'a DevicePathNode
Create a DevicePathNode
reference from an opaque pointer.
§Safety
The input pointer must point to valid data. That data must
remain valid for the lifetime 'a
, and cannot be mutated during
that lifetime.
sourcepub const fn as_ffi_ptr(&self) -> *const FfiDevicePath
pub const fn as_ffi_ptr(&self) -> *const FfiDevicePath
Cast to a FfiDevicePath
pointer.
sourcepub const fn device_type(&self) -> DeviceType
pub const fn device_type(&self) -> DeviceType
Type of device
sourcepub const fn sub_type(&self) -> DeviceSubType
pub const fn sub_type(&self) -> DeviceSubType
Sub type of device
sourcepub const fn full_type(&self) -> (DeviceType, DeviceSubType)
pub const fn full_type(&self) -> (DeviceType, DeviceSubType)
Tuple of the node’s type and subtype.
sourcepub const fn length(&self) -> u16
pub const fn length(&self) -> u16
Size (in bytes) of the full DevicePathNode
, including the header.
sourcepub fn is_end_entire(&self) -> bool
pub fn is_end_entire(&self) -> bool
True if this node ends an entire DevicePath
.
sourcepub fn as_enum(&self) -> Result<DevicePathNodeEnum<'_>, NodeConversionError>
pub fn as_enum(&self) -> Result<DevicePathNodeEnum<'_>, NodeConversionError>
Convert from a generic DevicePathNode
reference to an enum
of more specific node types.
sourcepub fn to_string(
&self,
bs: &BootServices,
display_only: DisplayOnly,
allow_shortcuts: AllowShortcuts
) -> Result<CString16, DevicePathToTextError>
Available on crate feature alloc
only.
pub fn to_string( &self, bs: &BootServices, display_only: DisplayOnly, allow_shortcuts: AllowShortcuts ) -> Result<CString16, DevicePathToTextError>
alloc
only.Transforms the device path node to its string representation using the
DevicePathToText
protocol.
Trait Implementations§
source§impl BuildNode for &DevicePathNode
impl BuildNode for &DevicePathNode
source§fn size_in_bytes(&self) -> Result<u16, BuildError>
fn size_in_bytes(&self) -> Result<u16, BuildError>
BuildError::NodeTooBig
if the node’s size
does not fit in a u16
.