Skip to content

Commit 9a2e5b5

Browse files
Add UEFI support
1 parent aa1ca63 commit 9a2e5b5

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mod borrowed;
3939
mod haiku;
4040
mod ohos;
4141
mod redox;
42+
mod uefi;
4243
mod uikit;
4344
mod unix;
4445
mod web;
@@ -51,6 +52,7 @@ pub use haiku::{HaikuDisplayHandle, HaikuWindowHandle};
5152
pub use ohos::{OhosDisplayHandle, OhosNdkWindowHandle};
5253
pub use redox::{OrbitalDisplayHandle, OrbitalWindowHandle};
5354
pub use uikit::{UiKitDisplayHandle, UiKitWindowHandle};
55+
pub use uefi::{UefiDisplayHandle, UefiWindowHandle};
5456
pub use unix::{
5557
DrmDisplayHandle, DrmWindowHandle, GbmDisplayHandle, GbmWindowHandle, WaylandDisplayHandle,
5658
WaylandWindowHandle, XcbDisplayHandle, XcbWindowHandle, XlibDisplayHandle, XlibWindowHandle,
@@ -207,6 +209,11 @@ pub enum RawWindowHandle {
207209
/// ## Availability Hints
208210
/// This variant is used on HaikuOS.
209211
Haiku(HaikuWindowHandle),
212+
/// A window handle for UEFI.
213+
///
214+
/// ## Availability Hints
215+
/// This variant is used on UEFI.
216+
Uefi(UefiWindowHandle),
210217
}
211218

212219
/// Display that wraps around a raw display handle.
@@ -341,6 +348,11 @@ pub enum RawDisplayHandle {
341348
/// ## Availability Hints
342349
/// This variant is used on HaikuOS.
343350
Haiku(HaikuDisplayHandle),
351+
/// A raw display handle for UEFI.
352+
///
353+
/// ## Availability Hints
354+
/// This variant is used on UEFI.
355+
Uefi(UefiDisplayHandle),
344356
}
345357

346358
/// An error that can occur while fetching a display or window handle.
@@ -413,6 +425,7 @@ from_impl!(RawDisplayHandle, Windows, WindowsDisplayHandle);
413425
from_impl!(RawDisplayHandle, Web, WebDisplayHandle);
414426
from_impl!(RawDisplayHandle, Android, AndroidDisplayHandle);
415427
from_impl!(RawDisplayHandle, Haiku, HaikuDisplayHandle);
428+
from_impl!(RawDisplayHandle, Uefi, UefiDisplayHandle);
416429

417430
from_impl!(RawWindowHandle, UiKit, UiKitWindowHandle);
418431
from_impl!(RawWindowHandle, AppKit, AppKitWindowHandle);
@@ -434,6 +447,7 @@ from_impl!(
434447
);
435448
from_impl!(RawWindowHandle, AndroidNdk, AndroidNdkWindowHandle);
436449
from_impl!(RawWindowHandle, Haiku, HaikuWindowHandle);
450+
from_impl!(RawWindowHandle, Uefi, UefiWindowHandle);
437451

438452
#[cfg(test)]
439453
mod tests {

src/uefi.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use core::ffi::c_void;
2+
use core::ptr::NonNull;
3+
4+
/// Raw display handle for UEFI.
5+
#[non_exhaustive]
6+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7+
pub struct UefiDisplayHandle {
8+
/// The UEFI Graphics Output Protocol handle.
9+
pub handle: NonNull<c_void>,
10+
}
11+
12+
impl UefiDisplayHandle {
13+
/// Create a new empty display handle.
14+
///
15+
///
16+
/// # Example
17+
///
18+
/// ```
19+
/// # use raw_window_handle::UefiDisplayHandle;
20+
/// let handle = UefiDisplayHandle::new(handle);
21+
/// ```
22+
pub fn new(handle: NonNull<c_void>) -> Self {
23+
Self { handle }
24+
}
25+
}
26+
27+
/// Raw window handle for UEFI.
28+
#[non_exhaustive]
29+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
30+
pub struct UefiWindowHandle {}
31+
32+
impl UefiWindowHandle {
33+
pub fn new() -> Self {
34+
Self {}
35+
}
36+
}

0 commit comments

Comments
 (0)