Skip to content

Commit 69c5174

Browse files
committed
uefi: improve doc
1 parent 98b3588 commit 69c5174

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

uefi/src/proto/device_path/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'a> DevicePathBuilder<'a> {
9999
/// Add a node to the device path.
100100
///
101101
/// An error will be returned if an [`END_ENTIRE`] node is passed to
102-
/// this function, as that node will be added when `finalize` is
102+
/// this function, as that node will be added when [`Self::finalize`] is
103103
/// called.
104104
///
105105
/// [`END_ENTIRE`]: uefi::proto::device_path::DeviceSubType::END_ENTIRE
@@ -150,6 +150,7 @@ impl<'a> DevicePathBuilder<'a> {
150150
}
151151
}
152152

153+
/// Reference to the backup storage for [`DevicePathBuilder`]
153154
#[derive(Debug)]
154155
enum BuilderStorage<'a> {
155156
Buf {

uefi/src/proto/device_path/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
//! other types in this module are DSTs, so pointers to the type are
7676
//! "fat" and not suitable for FFI.
7777
//!
78+
//! * [`PoolDevicePath`] is an owned device path on the UEFI heap.
79+
//!
7880
//! All of these types use a packed layout and may appear on any byte
7981
//! boundary.
8082
//!
@@ -133,6 +135,10 @@ opaque_type! {
133135
}
134136

135137
/// Device path allocated from UEFI pool memory.
138+
///
139+
/// Please note that this differs from <code>Box<[DevicePath]></code>. Although
140+
/// both represent owned values, a <code>Box<[DevicePath]></code> is on the Rust
141+
/// heap which may or may not be backed by the UEFI heap.
136142
#[derive(Debug)]
137143
pub struct PoolDevicePath(pub(crate) PoolAllocation);
138144

@@ -392,11 +398,15 @@ impl DevicePathInstance {
392398
}
393399

394400
/// Returns a boxed copy of that value.
401+
///
402+
/// The semantics slightly differs from a [`PoolDevicePath`] but is
403+
/// generally more idiomatic to use.
395404
#[cfg(feature = "alloc")]
396405
#[must_use]
397406
pub fn to_boxed(&self) -> Box<Self> {
398407
let data = self.data.to_owned();
399408
let data = data.into_boxed_slice();
409+
// SAFETY: This is safe as a DevicePath has the same layout.
400410
unsafe { mem::transmute(data) }
401411
}
402412
}
@@ -581,12 +591,16 @@ impl DevicePath {
581591
&self.data
582592
}
583593

584-
/// Returns a boxed copy of that value.
594+
/// Returns a boxed copy of that value on the Rust heap.
595+
///
596+
/// The semantics slightly differs from a [`PoolDevicePath`] but is
597+
/// generally more idiomatic to use.
585598
#[cfg(feature = "alloc")]
586599
#[must_use]
587600
pub fn to_boxed(&self) -> Box<Self> {
588601
let data = self.data.to_owned();
589602
let data = data.into_boxed_slice();
603+
// SAFETY: This is safe as a DevicePath has the same layout.
590604
unsafe { mem::transmute(data) }
591605
}
592606

0 commit comments

Comments
 (0)