Skip to content

Commit a743ac1

Browse files
authored
Merge pull request #858 from nicholasbishop/bishop-handle-event-methods
uefi: Add raw pointer Event/Handle methods
2 parents 756753d + 1432370 commit a743ac1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- `DevicePath::to_boxed`, `DevicePath::to_owned`, and `DevicePath::as_bytes`
77
- `DevicePathInstance::to_boxed`, `DevicePathInstance::to_owned`, and `DevicePathInstance::as_bytes`
88
- `DevicePathNode::data`
9+
- Added `Event::from_ptr`, `Event::as_ptr`, and `Handle::as_ptr`.
910

1011
### Changed
1112
- Renamed `LoadImageSource::FromFilePath` to `LoadImageSource::FromDevicePath`

uefi/src/data_types/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ impl Handle {
3636
// shorthand for "|ptr| Self(ptr)"
3737
NonNull::new(ptr).map(Self)
3838
}
39+
40+
/// Get the underlying raw pointer.
41+
#[must_use]
42+
pub fn as_ptr(&self) -> *mut c_void {
43+
self.0.as_ptr()
44+
}
3945
}
4046

4147
/// Handle to an event structure, guaranteed to be non-null.
@@ -56,6 +62,21 @@ impl Event {
5662
pub const unsafe fn unsafe_clone(&self) -> Self {
5763
Self(self.0)
5864
}
65+
66+
/// Create an `Event` from a raw pointer.
67+
///
68+
/// # Safety
69+
///
70+
/// The caller must ensure that the pointer is valid.
71+
pub unsafe fn from_ptr(ptr: *mut c_void) -> Option<Self> {
72+
NonNull::new(ptr).map(Self)
73+
}
74+
75+
/// Get the underlying raw pointer.
76+
#[must_use]
77+
pub fn as_ptr(&self) -> *mut c_void {
78+
self.0.as_ptr()
79+
}
5980
}
6081

6182
/// Trait for querying the alignment of a struct.

0 commit comments

Comments
 (0)