Allocator

Trait Allocator 

Source
trait Allocator<const N: usize> {
    // Required methods
    fn initializer(    ) -> unsafe fn(PhysAddr, usize) -> Result<Pin<Box<Self>>, Error>;
    fn alloc(&mut self, page_count: usize) -> Option<PhysAddr>;
    fn free(&mut self, addr: PhysAddr, page_count: usize);
}
Expand description

This trait abstracts over different page frame allocator implementations.

Required Methods§

Source

fn initializer() -> unsafe fn(PhysAddr, usize) -> Result<Pin<Box<Self>>, Error>

Returns an initializer function that can be used to create an instance of the allocator. The initializer function takes a physical address and the amount of pages needed.

Safety:

  • The returned function must only be called with a useable and valid physical address.
Source

fn alloc(&mut self, page_count: usize) -> Option<PhysAddr>

Source

fn free(&mut self, addr: PhysAddr, page_count: usize)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const N: usize> Allocator<N> for Allocator<N>