pub fn device_path_node_count(
device_path: *const Protocol,
) -> Result<(usize, usize), Status>Expand description
Returns the count of nodes and size (in bytes) of the given device path.
count and size outputs both include the terminating end node.
§SAFETY
device_path input must be a valid pointer (i.e. not null) that points to a well-formed device path that conforms to UEFI spec 2.11 section 10.
§Examples
#![feature(pointer_byte_offsets)]
use patina_internal_device_path::device_path_node_count;
use r_efi::efi;
let device_path_bytes = [
efi::protocols::device_path::TYPE_HARDWARE,
efi::protocols::device_path::Hardware::SUBTYPE_PCI,
0x6, //length[0]
0x0, //length[1]
0x0, //func
0x1C, //device
efi::protocols::device_path::TYPE_HARDWARE,
efi::protocols::device_path::Hardware::SUBTYPE_PCI,
0x6, //length[0]
0x0, //length[1]
0x0, //func
0x0, //device
efi::protocols::device_path::TYPE_HARDWARE,
efi::protocols::device_path::Hardware::SUBTYPE_PCI,
0x6, //length[0]
0x0, //length[1]
0x2, //func
0x0, //device
efi::protocols::device_path::TYPE_END,
efi::protocols::device_path::End::SUBTYPE_ENTIRE,
0x4, //length[0]
0x00, //length[1]
];
let device_path_ptr = device_path_bytes.as_ptr() as *const efi::protocols::device_path::Protocol;
let (nodes, length) = device_path_node_count(device_path_ptr).unwrap();
assert_eq!(nodes, 4);
assert_eq!(length, device_path_bytes.len());