Skip to main content

Pager

Struct Pager 

Source
pub struct Pager<F: VfsFile, W: WalBarrier> { /* private fields */ }

Implementations§

Source§

impl<F: VfsFile, W: WalBarrier> Pager<F, W>

Source

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.

Source

pub fn wal_barrier(&self) -> &W

Source

pub fn read_page(&self, page_id: u32) -> Result<Page, PagerError>

Read a page (cache-aware)

Source

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).

Source

pub fn write_page(&self, page_id: u32, page: Page) -> Result<(), PagerError>

Write a page (cache-aware)

Source

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).

Source

pub fn allocate_page(&self, page_type: PageType) -> Result<Page, PagerError>

Allocate a new page

Source

pub fn reserve_contig_extent( &self, n_pages: u32, ) -> Result<ExtentId, PagerError>

Reserve a contiguous extent of vector pages.

Source

pub fn free_page(&self, page_id: u32) -> Result<(), PagerError>

Free a page (return to freelist)

Source

pub fn enable_deferred_reclamation(&self) -> Result<(), PagerError>

Source

pub fn deferred_reclamation_pages( &self, ) -> Result<(Vec<u32>, Vec<u32>), PagerError>

Source

pub fn restore_deferred_reclamation( &self, pages: &[u32], ) -> Result<(), PagerError>

Source

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.

Source

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.

Source

pub fn free_page_count(&self) -> Result<u32, PagerError>

Get database header Pages available to the allocator, including pages on unloaded trunks.

Source

pub fn header(&self) -> Result<DatabaseHeader, PagerError>

Source

pub fn physical_header(&self) -> Result<PhysicalFileHeader, PagerError>

Source

pub fn update_physical_header( &self, physical: PhysicalFileHeader, ) -> Result<(), PagerError>

Source

pub fn page_count(&self) -> Result<u32, PagerError>

Get page count

Source

pub fn flush(&self) -> Result<(), PagerError>

Flush all dirty pages to disk

Source

pub fn sync(&self) -> Result<(), PagerError>

Sync file to disk (fsync)

Source

pub fn cache_stats(&self) -> CacheStats

Get cache statistics

Source

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).

Source

pub fn cache_capacity(&self) -> usize

Preallocated page-cache slots — the sizing this process derived from its page-cache budget share.

Source

pub fn dirty_page_count(&self) -> usize

Count dirty pages currently in the page cache.

Source

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.

Source

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.

Source

pub fn path(&self) -> &Path

Get database file path

Source

pub fn is_read_only(&self) -> bool

Check if database is read-only

Source

pub fn file_size(&self) -> Result<u64, PagerError>

Get file size in bytes

Source

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.

Source

pub fn write_header_and_sync(&self) -> Result<(), PagerError>

Write header and sync to disk (public for checkpointer).

Source

pub fn set_checkpoint_in_progress( &self, in_progress: bool, target_lsn: u64, ) -> Result<(), PagerError>

Set the checkpoint_in_progress flag in the header.

Source

pub fn complete_checkpoint(&self, lsn: u64) -> Result<(), PagerError>

Update the checkpoint LSN and clear the in-progress flag.

Trait Implementations§

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>
where Mutex<F>: Send, W: Send,

§

impl<F, W> Sync for Pager<F, W>
where Mutex<F>: Sync, W: Sync,

§

impl<F, W> Unpin for Pager<F, W>
where Mutex<F>: Unpin, W: Unpin,

§

impl<F, W> UnsafeUnpin for Pager<F, W>

§

impl<F, W> UnwindSafe for Pager<F, W>
where Mutex<F>: UnwindSafe, W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.