forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uefi: helpers: Introduce OwnedDevicePath
This PR is split off from rust-lang#135368 to reduce noise. No real functionality changes, just some quality of life improvements. Introduce `device_path_to_text_raw` which creates a Box<[u16]> (UTF-16 string) from path instead of creating OsString. OsString internally is stored as WTF-8, which means converting OsString to Box<[u16]> requires allocation. This is not ideal for std::fs APIs where we need to perform Device Path Protocol matching while opening a volume, and create a UEFI UTF-16 string from the remaining path (which represents file path inside a volume). This remaining path is never used on the Rust side, and thus does not need to be converted to WTF-8 to be used. By introducing direct conversion to Box<[u16]>, we shorten the conversions from `EFI_DEVICE_PATH_PROTOCOL` -> WTF-8 -> UTF-16 to `EFI_DEVICE_PATH_PROTOCOL` -> UTF-16 which is required in every file open operation. Also implement Debug for OwnedDevicePath for some quality of life improvements. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
- Loading branch information
Showing
2 changed files
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters