pub struct Pager<F: VfsFile, W: WalBarrier> { /* private fields */ }Implementations§
Source§impl<F: VfsFile, W: WalBarrier> Pager<F, W>
impl<F: VfsFile, W: WalBarrier> Pager<F, W>
Sourcepub fn open_owned(
file: F,
path: PathBuf,
config: PagerConfig,
wal: W,
create: bool,
) -> Result<Self, PagerError>
pub fn open_owned( file: F, path: PathBuf, config: PagerConfig, wal: W, create: bool, ) -> Result<Self, PagerError>
Use an already-owned file. The host retains exclusive ownership until
this pager is dropped, and supplies the native WAL/encryption policy.
create is explicit: a corrupt or empty existing file is never recreated.
pub fn wal_barrier(&self) -> &W
Sourcepub fn read_page_no_checksum(&self, page_id: u32) -> Result<Page, PagerError>
pub fn read_page_no_checksum(&self, page_id: u32) -> Result<Page, PagerError>
Read a page without verifying checksum (for encrypted pages)
Use this when the page content has its own integrity protection (e.g., AES-GCM authentication tag for encrypted pages).
Sourcepub fn write_page(&self, page_id: u32, page: Page) -> Result<(), PagerError>
pub fn write_page(&self, page_id: u32, page: Page) -> Result<(), PagerError>
Write a page (cache-aware)
Sourcepub fn write_page_no_checksum(
&self,
page_id: u32,
page: Page,
) -> Result<(), PagerError>
pub fn write_page_no_checksum( &self, page_id: u32, page: Page, ) -> Result<(), PagerError>
Write a page without updating checksum (for encrypted pages)
Use this when the page content has its own integrity protection (e.g., AES-GCM authentication tag for encrypted pages).
Sourcepub fn allocate_page(&self, page_type: PageType) -> Result<Page, PagerError>
pub fn allocate_page(&self, page_type: PageType) -> Result<Page, PagerError>
Allocate a new page
Sourcepub fn reserve_contig_extent(
&self,
n_pages: u32,
) -> Result<ExtentId, PagerError>
pub fn reserve_contig_extent( &self, n_pages: u32, ) -> Result<ExtentId, PagerError>
Reserve a contiguous extent of vector pages.
Sourcepub fn free_page(&self, page_id: u32) -> Result<(), PagerError>
pub fn free_page(&self, page_id: u32) -> Result<(), PagerError>
Free a page (return to freelist)
pub fn enable_deferred_reclamation(&self) -> Result<(), PagerError>
pub fn deferred_reclamation_pages( &self, ) -> Result<(Vec<u32>, Vec<u32>), PagerError>
pub fn restore_deferred_reclamation( &self, pages: &[u32], ) -> Result<(), PagerError>
Sourcepub fn complete_deferred_publication(
&self,
retained: &[u32],
released: &[u32],
) -> Result<(), PagerError>
pub fn complete_deferred_publication( &self, retained: &[u32], released: &[u32], ) -> Result<(), PagerError>
The caller has durably published a catalog that retains retained
and no longer names released, after waiting for old tree readers.
Sourcepub fn free_retired_pages(&self, pages: &[u32]) -> Result<(), PagerError>
pub fn free_retired_pages(&self, pages: &[u32]) -> Result<(), PagerError>
Return a fully validated, unpublished tree generation in one allocator mutation. Call only after its removal from the manifest is durable.
Sourcepub fn free_page_count(&self) -> Result<u32, PagerError>
pub fn free_page_count(&self) -> Result<u32, PagerError>
Get database header Pages available to the allocator, including pages on unloaded trunks.
pub fn header(&self) -> Result<DatabaseHeader, PagerError>
pub fn physical_header(&self) -> Result<PhysicalFileHeader, PagerError>
pub fn update_physical_header( &self, physical: PhysicalFileHeader, ) -> Result<(), PagerError>
Sourcepub fn page_count(&self) -> Result<u32, PagerError>
pub fn page_count(&self) -> Result<u32, PagerError>
Get page count
Sourcepub fn flush(&self) -> Result<(), PagerError>
pub fn flush(&self) -> Result<(), PagerError>
Flush all dirty pages to disk
Sourcepub fn sync(&self) -> Result<(), PagerError>
pub fn sync(&self) -> Result<(), PagerError>
Sync file to disk (fsync)
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn cache_len(&self) -> usize
pub fn cache_len(&self) -> usize
Pages currently resident in the page cache. Slots are fixed size, so this times the page size is the cache’s memory footprint (ADR 0073 §2).
Sourcepub fn cache_capacity(&self) -> usize
pub fn cache_capacity(&self) -> usize
Preallocated page-cache slots — the sizing this process derived from its page-cache budget share.
Sourcepub fn dirty_page_count(&self) -> usize
pub fn dirty_page_count(&self) -> usize
Count dirty pages currently in the page cache.
Sourcepub fn dirty_fraction(&self) -> f64
pub fn dirty_fraction(&self) -> f64
Estimated fraction of the page cache holding dirty pages.
Returned in [0, 1]. Used by the background writer to
decide when to kick in aggressive flushing.
Sourcepub fn flush_some_dirty(&self, max: usize) -> Result<usize, PagerError>
pub fn flush_some_dirty(&self, max: usize) -> Result<usize, PagerError>
Flush up to max dirty pages from the cache. Returns the
number actually written. Background-writer entry point —
reuses the same persistence path as flush() but bounded.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Check if database is read-only
Sourcepub fn file_size(&self) -> Result<u64, PagerError>
pub fn file_size(&self) -> Result<u64, PagerError>
Get file size in bytes
Sourcepub fn read_manifest_page(&self) -> Result<Page, PagerError>
pub fn read_manifest_page(&self) -> Result<Page, PagerError>
Read the internal manifest page (page 1), the zone the superblock roots.
ADR 0074 §2: manifest corruption fails the open didactically, naming the zone — it never falls back to a sidecar and never returns garbage.
Sourcepub fn write_header_and_sync(&self) -> Result<(), PagerError>
pub fn write_header_and_sync(&self) -> Result<(), PagerError>
Write header and sync to disk (public for checkpointer).
Sourcepub fn set_checkpoint_in_progress(
&self,
in_progress: bool,
target_lsn: u64,
) -> Result<(), PagerError>
pub fn set_checkpoint_in_progress( &self, in_progress: bool, target_lsn: u64, ) -> Result<(), PagerError>
Set the checkpoint_in_progress flag in the header.
Sourcepub fn complete_checkpoint(&self, lsn: u64) -> Result<(), PagerError>
pub fn complete_checkpoint(&self, lsn: u64) -> Result<(), PagerError>
Update the checkpoint LSN and clear the in-progress flag.
Trait Implementations§
Source§impl<F: VfsFile, W: WalBarrier> PageStore for Pager<F, W>
impl<F: VfsFile, W: WalBarrier> PageStore for Pager<F, W>
fn read_page(&self, id: u32) -> Result<Page, PagerError>
fn write_page(&self, id: u32, page: Page) -> Result<(), PagerError>
fn allocate_page(&self, kind: PageType) -> Result<Page, PagerError>
fn free_page(&self, id: u32) -> Result<(), PagerError>
fn page_count(&self) -> Result<u32, PagerError>
fn prefetch_hint(&self, _page_id: u32)
Auto Trait Implementations§
impl<F, W> !Freeze for Pager<F, W>
impl<F, W> RefUnwindSafe for Pager<F, W>
impl<F, W> Send for Pager<F, W>
impl<F, W> Sync for Pager<F, W>
impl<F, W> Unpin for Pager<F, W>
impl<F, W> UnsafeUnpin for Pager<F, W>
impl<F, W> UnwindSafe for Pager<F, W>
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
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> ⓘ
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> ⓘ
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