Skip to content

Conversation

@phip1611
Copy link
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
@phip1611 phip1611 force-pushed the handle-convenience branch 2 times, most recently from 312e542 to a3c3e1e Compare January 19, 2026 08:25
@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
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.

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.
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.

3 participants