Skip to main content

CommitSnapshot

Struct CommitSnapshot 

Source
pub struct CommitSnapshot { /* private fields */ }
Expand description

A materializable database state: the replay of all valid frames up to a COMMIT.

This is the ONLY independently-materializable WAL state. page_version resolves a page to its image as of this commit (the newest frame ≤ this commit that rewrote the page, else the acquired base image). A frame between commits is never a snapshot.

Implementations§

Source§

impl CommitSnapshot

Source

pub fn id(&self) -> CommitId

This snapshot’s CommitId.

Source

pub fn db_size_after_commit(&self) -> u32

The database page count once this commit is materialized.

Source

pub fn checksum_valid(&self) -> bool

Whether the WAL frame chain up to and including this commit’s COMMIT frame validated against the cumulative WAL checksum (file-format §4.2).

true is the spec-conformant case: every frame’s stored (checksum1, checksum2) equalled the running checksum advanced over the frame’s first 8 header bytes plus its full page data, seeded from the WAL header checksum. false means the chain broke at or before this commit — the salt + commit-marker admission accepted it, but it is residue (post-reset leftover, tampering, or corruption). Such a commit is deliberately KEPT (not dropped) so the forensic layer can mark it; a consumer that wants only trustworthy state filters on this flag.

Source

pub fn lsn(&self) -> WalLsn

The salt-qualified WalLsn of this commit (the [H] adapter seam).

Source

pub fn page_numbers(&self) -> Vec<u32>

The 1-based page numbers this commit materialized (base ∪ committed frames up to this commit, capped to db_size_after_commit), ascending.

The carve-at-snapshot primitive iterates these to drive the carving primitives over each page image, WITHOUT assuming the pages form a contiguous 1..=db_size range (a truncating commit or a sparse base image can leave gaps). Every returned page resolves via Self::page_version.

Source

pub fn page_version(&self, page_no: u32) -> Option<CommittedPageVersion>

The image of page_no as of this commit, or None for a page beyond the committed database size that the WAL never rewrote.

Source

pub fn tables(&self) -> Vec<SnapshotTable>

The user tables AS OF this commit, parsed from the snapshot’s OWN page 1 (the sqlite_master b-tree), NOT from the live database.

A rootpage can be dropped and reused by a different table across commits, so the schema MUST come from the snapshot itself — reading today’s live schema would mis-attribute a historical b-tree. Returns one SnapshotTable per type='table' row whose name is not an internal sqlite_* table, carrying its rootpage, parsed column names, and a WITHOUT ROWID flag (file-format §2.4). Best-effort and panic-free: an unreadable page-1 schema yields an empty vector.

Source

pub fn read_table( &self, rootpage: u32, column_count: usize, ) -> Result<Vec<(i64, Vec<Value>)>, Error>

Read every row of the table b-tree rooted at rootpage AS OF this commit, resolving overflow chains through the snapshot’s OWN materialized pages, in rowid order.

This is the snapshot-scoped counterpart to Database::read_table: it shares the SAME b-tree/overflow walk via an internal page-source abstraction, so a large row decodes with the page content as of this commit (not stale/future content the live view would supply). column_count drives only the INTEGER PRIMARY KEY rowid-alias rule (pass the table’s declared arity, e.g. SnapshotTable::columns.len()). Returns (rowid, values) per row.

Bounded and panic-free on hostile input, exactly as the live path: a cyclic/over-deep b-tree or overflow chain surfaces a typed Error rather than looping or panicking.

Trait Implementations§

Source§

impl Clone for CommitSnapshot

Source§

fn clone(&self) -> CommitSnapshot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommitSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CommitSnapshot

Source§

impl PartialEq for CommitSnapshot

Source§

fn eq(&self, other: &CommitSnapshot) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CommitSnapshot

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.