Skip to main content

CheckpointTarget

Trait CheckpointTarget 

Source
pub trait CheckpointTarget {
    // Required methods
    fn write_page(
        &mut self,
        cx: &Cx,
        page_no: PageNumber,
        data: &[u8],
    ) -> Result<()>;
    fn truncate_db(&mut self, cx: &Cx, n_pages: u32) -> Result<()>;
    fn sync_db(&mut self, cx: &Cx) -> Result<()>;

    // Provided method
    fn read_page_if_supported(
        &self,
        _cx: &Cx,
        _page_no: PageNumber,
        _buf: &mut [u8],
    ) -> Result<Option<usize>> { ... }
}
Expand description

Write-back interface for checkpoint page transfers.

Implementors push WAL frame content into the main database file. This trait is intentionally not sealed so that fsqlite-core can provide the concrete adapter at runtime.

Required Methods§

Source

fn write_page( &mut self, cx: &Cx, page_no: PageNumber, data: &[u8], ) -> Result<()>

Write data for page_no directly to the database file.

Source

fn truncate_db(&mut self, cx: &Cx, n_pages: u32) -> Result<()>

Truncate the database file to exactly n_pages pages.

Source

fn sync_db(&mut self, cx: &Cx) -> Result<()>

Sync the database file to stable storage.

Provided Methods§

Source

fn read_page_if_supported( &self, _cx: &Cx, _page_no: PageNumber, _buf: &mut [u8], ) -> Result<Option<usize>>

Read back a page’s current on-disk content, if the target supports it. Used by the post-checkpoint checksum verification path (bd-yfdb6) to confirm that the DB file matches the expected state before the WAL is truncated.

The default implementation returns None, which skips verification. Concrete CheckpointTargets that back a real VFS file should override this with the equivalent of vfs.read(db_fd, buf, offset).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§