Implement FrameAllocator for mutable refs of impls.

This commit is contained in:
4lDO2
2022-07-17 13:25:34 +02:00
parent 2f16dddf25
commit c847b1e2a8
+19
View File
@@ -20,6 +20,7 @@ impl FrameCount {
}
}
#[derive(Debug)]
pub struct FrameUsage {
used: FrameCount,
total: FrameCount,
@@ -58,3 +59,21 @@ pub trait FrameAllocator {
unsafe fn usage(&self) -> FrameUsage;
}
impl<T> FrameAllocator for &mut T where T: FrameAllocator {
unsafe fn allocate(&mut self, count: FrameCount) -> Option<PhysicalAddress> {
T::allocate(self, count)
}
unsafe fn free(&mut self, address: PhysicalAddress, count: FrameCount) {
T::free(self, address, count)
}
unsafe fn allocate_one(&mut self) -> Option<PhysicalAddress> {
T::allocate_one(self)
}
unsafe fn free_one(&mut self, address: PhysicalAddress) {
T::free_one(self, address)
}
unsafe fn usage(&self) -> FrameUsage {
T::usage(self)
}
}