Skip to main content

PriorSnapshot

Struct PriorSnapshot 

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

A read-only, page-addressable image of the database AS IT WAS BEFORE the last transaction (design §4/§5). The temporal inverse of CommitSnapshot: prior[pgno] is the rollback-journal image where present, else the live main page. Diffing this against the current database yields the last transaction’s deletions (rowid present here, absent now) and modifications (present in both, values differ — the journal carries the OLD value).

Returned by Database::rollback_prior as a DISTINCT type, never a Database, so prior/deleted rows can never be read as “live” (secure-by-design). Shares ONE b-tree/overflow walk with the live and commit-snapshot reads via the internal PageSource seam.

Implementations§

Source§

impl PriorSnapshot

Source

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

The user tables AS OF the prior state, parsed from the snapshot’s OWN page 1 (the prior sqlite_master), NOT the live database — so a DROP/CREATE in the last transaction is interpreted against the prior schema. Best-effort and panic-free: an unreadable page-1 schema yields an empty vector.

Source

pub fn schema_sql(&self) -> BTreeMap<String, String>

The PRIOR sqlite_master as a name -> CREATE SQL map for every user table, parsed from the snapshot’s OWN page 1 — the prior-schema half of the Detector-B sidecar schema-change comparison (docs/design/drop-recreate-attribution.md).

The counterpart to Database::schema_sql read against the pre-transaction state the -journal preserves, so a DROP/CREATE/ALTER in the last transaction is interpreted against the prior schema. Best-effort and panic-free: an unreadable prior page-1 schema yields an empty map.

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 the prior state, in rowid order, resolving overflow chains through the snapshot’s OWN pages. The snapshot-scoped counterpart to Database::read_table: a typed Error (never a panic) on a cyclic/over-deep b-tree or overflow chain.

Source

pub fn grew_db(&self) -> bool

Whether the last transaction GREW the database (a journal page number exceeded the current main-db page count). Pages beyond the prior size are new — their pre-images were not journaled — which bounds what rolls back.

Source

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

Read the table rooted at rootpage AS OF the prior state, returning each row’s rowid, values, AND the 1-based LEAF page it was decoded from — the per-row page provenance the forensic diff attaches to a recovered prior row. Shares decode_leaf_cell with the standard read; a typed Error (never a panic) on a cyclic/over-deep b-tree.

Trait Implementations§

Source§

impl Clone for PriorSnapshot

Source§

fn clone(&self) -> PriorSnapshot

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 PriorSnapshot

Source§

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

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

impl Eq for PriorSnapshot

Source§

impl PartialEq for PriorSnapshot

Source§

fn eq(&self, other: &PriorSnapshot) -> 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 PriorSnapshot

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.