pub struct PageAllocator { /* private fields */ }Expand description
Page allocator for dynamic page allocation
Manages free list and bitmap tracking for efficient page reuse.
Implementations§
Source§impl PageAllocator
impl PageAllocator
Sourcepub fn new(header: &PersistentHeaderV3) -> Self
pub fn new(header: &PersistentHeaderV3) -> Self
Create a new page allocator
§Arguments
header- V3 persistent header with free_page_list_head and total_pages
§Returns
Initialized PageAllocator with sparse bitmap for O(1) initialization
§Optimization
The bitmap is SPARSE: only pages 0 and 1 (reserved) are pre-initialized. Pages 2+ are “implicitly free” until actually allocated. This eliminates the O(N) bitmap initialization on open.
See get_page_state() for how pages beyond bitmap.len() are handled.
Sourcepub fn allocate(&mut self) -> NativeResult<u64>
pub fn allocate(&mut self) -> NativeResult<u64>
Sourcepub fn deallocate(&mut self, page_id: u64) -> NativeResult<()>
pub fn deallocate(&mut self, page_id: u64) -> NativeResult<()>
Sourcepub fn get_page_state(&self, page_id: u64) -> NativeResult<PageState>
pub fn get_page_state(&self, page_id: u64) -> NativeResult<PageState>
Sourcepub fn pin_page(&mut self, page_id: u64) -> NativeResult<()>
pub fn pin_page(&mut self, page_id: u64) -> NativeResult<()>
Sourcepub fn unpin_page(&mut self, page_id: u64) -> NativeResult<()>
pub fn unpin_page(&mut self, page_id: u64) -> NativeResult<()>
Sourcepub fn free_list_head(&self) -> u64
pub fn free_list_head(&self) -> u64
Sourcepub fn total_pages(&self) -> u64
pub fn total_pages(&self) -> u64
Sourcepub fn page_offset(page_id: u64) -> NativeResult<u64>
pub fn page_offset(page_id: u64) -> NativeResult<u64>
Sourcepub fn validate_checksum(
page_data: &[u8],
stored_checksum: u64,
) -> NativeResult<()>
pub fn validate_checksum( page_data: &[u8], stored_checksum: u64, ) -> NativeResult<()>
Trait Implementations§
Source§impl Clone for PageAllocator
impl Clone for PageAllocator
Source§fn clone(&self) -> PageAllocator
fn clone(&self) -> PageAllocator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PageAllocator
impl RefUnwindSafe for PageAllocator
impl Send for PageAllocator
impl Sync for PageAllocator
impl Unpin for PageAllocator
impl UnsafeUnpin for PageAllocator
impl UnwindSafe for PageAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more