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
impl CommitSnapshot
Sourcepub fn db_size_after_commit(&self) -> u32
pub fn db_size_after_commit(&self) -> u32
The database page count once this commit is materialized.
Sourcepub fn checksum_valid(&self) -> bool
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.
Sourcepub fn page_numbers(&self) -> Vec<u32>
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.
Sourcepub fn page_version(&self, page_no: u32) -> Option<CommittedPageVersion>
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.
Sourcepub fn tables(&self) -> Vec<SnapshotTable>
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.
Sourcepub fn read_table(
&self,
rootpage: u32,
column_count: usize,
) -> Result<Vec<(i64, Vec<Value>)>, Error>
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
impl Clone for CommitSnapshot
Source§fn clone(&self) -> CommitSnapshot
fn clone(&self) -> CommitSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more