pub struct PageManager { /* private fields */ }Expand description
Manages page allocation and deallocation for a database file.
Implementations§
Source§impl PageManager
impl PageManager
Sourcepub fn new(
db_path: PathBuf,
page_size: usize,
existing_pages: u64,
fsm: Arc<FreeSpaceManager>,
) -> Self
pub fn new( db_path: PathBuf, page_size: usize, existing_pages: u64, fsm: Arc<FreeSpaceManager>, ) -> Self
Create a new page manager.
existing_pages is the number of pages already present in the file
(determined from file metadata on open).
Sourcepub fn total_pages(&self) -> u64
pub fn total_pages(&self) -> u64
Total number of pages managed (allocated + free).
Sourcepub fn allocate_page(&self) -> u64
pub fn allocate_page(&self) -> u64
Allocate a new page index.
Tries the FSM first for a free page; if none available,
extends the file (incrementing next_page).
Sourcepub fn free_page(&self, page_idx: u64)
pub fn free_page(&self, page_idx: u64)
Free a previously allocated page.
The page is added back to the FSM for future reuse.
Sourcepub fn free_pages(&self, start_page_idx: u64, num_pages: u64)
pub fn free_pages(&self, start_page_idx: u64, num_pages: u64)
Free a range of pages.
Sourcepub fn fsm(&self) -> &Arc<FreeSpaceManager> ⓘ
pub fn fsm(&self) -> &Arc<FreeSpaceManager> ⓘ
Access the underlying free space manager.
Sourcepub fn page_offset(&self, page_idx: u64) -> u64
pub fn page_offset(&self, page_idx: u64) -> u64
Get the byte offset for a page index.
Sourcepub fn extend_file(&self, num_pages: u64) -> Result<u64>
pub fn extend_file(&self, num_pages: u64) -> Result<u64>
Extend the database file by num_pages pages.
This writes zero-filled pages to the end of the file. Returns the starting page index of the newly extended region.
Auto Trait Implementations§
impl !Freeze for PageManager
impl RefUnwindSafe for PageManager
impl Send for PageManager
impl Sync for PageManager
impl Unpin for PageManager
impl UnsafeUnpin for PageManager
impl UnwindSafe for PageManager
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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