Skip to content

uefi: significantly improve ergonomics of Handle (device path and component2 protocols)#1858

Merged
phip1611 merged 5 commits intomainfrom
handle-convenience
Feb 2, 2026
Merged

uefi: significantly improve ergonomics of Handle (device path and component2 protocols)#1858
phip1611 merged 5 commits intomainfrom
handle-convenience

Conversation

@phip1611
Copy link
Copy Markdown
Member

@phip1611 phip1611 commented Jan 2, 2026

This PR prepares and implements a significant simplification of handling typical tasks with handles: printing a device path and using the component2 protocol.

  • impl Display for DevicePath and ScopedProtocol
  • add boot::open_protocol_[exclusive]if_exists() helpers (eventually replacing the base methods which we could deprecate)
  • add Handle::device_path() and Handle::component_name()

This improves the convenience and ergonomics in every Rust uefi code base I've seen so far at work and in private projects.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@phip1611 phip1611 self-assigned this Jan 2, 2026
@phip1611 phip1611 force-pushed the handle-convenience branch 4 times, most recently from 8dd6b43 to b9c1651 Compare January 2, 2026 11:55
Comment thread uefi/src/boot.rs Outdated
Comment thread uefi/src/proto/device_path/mod.rs
@phip1611 phip1611 force-pushed the handle-convenience branch 2 times, most recently from 312e542 to a3c3e1e Compare January 19, 2026 08:25
Comment thread uefi/src/data_types/mod.rs
Comment thread uefi/src/data_types/mod.rs Outdated
Comment thread uefi/src/data_types/mod.rs Outdated
Comment thread uefi/src/data_types/mod.rs Outdated
@phip1611 phip1611 force-pushed the handle-convenience branch 2 times, most recently from 24fe1fb to 7661a74 Compare January 25, 2026 09:47
@phip1611
Copy link
Copy Markdown
Member Author

@nicholasbishop Every time I split things into smaller PRs and clean up the commit history, they somehow grow again 😀 Let me know if this size works for you.

@phip1611 phip1611 force-pushed the handle-convenience branch 4 times, most recently from b8abfa6 to 9f03d1a Compare January 25, 2026 11:11
@phip1611 phip1611 force-pushed the handle-convenience branch 4 times, most recently from 6cc347d to f5217cf Compare February 2, 2026 10:37
This is a pre-requisite for the next commit that implements
Display. Display comes with a to_string() method already.
For device paths, it is very convenient to use the DevicePathToText
protocol to visualize/print the device path. By providing a
convenient Display impl, we improve the ergonomics of device paths
significantly and reducing boilerplate.
Clean up the mess and follow our convention:

- pub mod
- mod
- pub use
- use
…_path()

In practice, UEFI applications frequently need to extract additional
metadata from handles for logging, debugging, and user-facing selection.
The Device Path and Component Name 2 protocols provide helpful information,
but accessing them repeatedly requires non-trivial boilerplate.

This change introduces convenience helpers on Handle to streamline
common queries and improve ergonomics when working with these protocols.
@phip1611 phip1611 enabled auto-merge February 2, 2026 12:16
@phip1611 phip1611 added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit 8c8eadf Feb 2, 2026
20 checks passed
@phip1611 phip1611 deleted the handle-convenience branch February 2, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants