Skip to content

Commit 88547ef

Browse files
committed
Add a deprecated dummy UnusedPhysFrame type to reduce breakage
1 parent c7d6e82 commit 88547ef

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/structures/paging/frame_alloc.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Traits for abstracting away frame allocation and deallocation.
22
3-
use crate::structures::paging::{PageSize, PhysFrame};
3+
use crate::structures::paging::{PageSize, PhysFrame, Size4KiB};
44

55
/// A trait for types that can allocate a frame of memory.
66
///
@@ -16,3 +16,22 @@ pub trait FrameDeallocator<S: PageSize> {
1616
/// Deallocate the given frame of memory.
1717
fn deallocate_frame(&mut self, frame: PhysFrame<S>);
1818
}
19+
20+
/// Represents a physical frame that is not used for any mapping.
21+
#[deprecated(note = "This wrapper type was removed. Use `PhysFrame` instead.")]
22+
#[derive(Debug)]
23+
pub struct UnusedPhysFrame<S: PageSize = Size4KiB>(PhysFrame<S>);
24+
25+
#[allow(deprecated)]
26+
impl<S: PageSize> UnusedPhysFrame<S> {
27+
/// Creates a new UnusedPhysFrame from the given frame.
28+
///
29+
/// ## Safety
30+
///
31+
/// This method is unsafe because the caller must guarantee
32+
/// that the given frame is unused.
33+
#[allow(clippy::new_ret_no_self)]
34+
pub unsafe fn new(frame: PhysFrame<S>) -> PhysFrame<S> {
35+
frame
36+
}
37+
}

src/structures/paging/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! Page tables translate virtual memory “pages” to physical memory “frames”.
44
55
pub use self::frame::PhysFrame;
6+
#[allow(deprecated)]
7+
pub use self::frame_alloc::UnusedPhysFrame;
68
pub use self::frame_alloc::{FrameAllocator, FrameDeallocator};
79
#[doc(no_inline)]
810
pub use self::mapper::MappedPageTable;

0 commit comments

Comments
 (0)