Skip to main content

SqliteStore

Struct SqliteStore 

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

A synchronous local database with validated snapshots and immutable operation history.

Implementations§

Source§

impl SqliteStore

Source

pub fn history_blocking( &self, after_sequence: u64, limit: u16, ) -> Result<HistoryPage, StoreError>

Read at most 1000 operations after a local sequence cursor without modifying history.

Source

pub fn recorded_operation_blocking( &self, id: OperationId, ) -> Result<Option<HistoryEntry>, StoreError>

The operation recorded under this identity, if any, whichever lineage recorded it.

Source§

impl SqliteStore

Source

pub fn backup_blocking(&self, to: &Path) -> Result<IntegrityReport, StoreError>

Copy the committed snapshot, full operation history and schema version into a new file, then verify the copy; an existing file is never overwritten.

When the store has a run store beside it, that is copied too, to <backup>.runs, and the report says so; the project backup file alone never contains runs.

Source§

impl SqliteStore

Source

pub fn open_blocking(path: impl AsRef<Path>) -> Result<Self, StoreError>

Create or open a database without writing to it; Self::initialize_blocking creates the schema.

Source

pub fn open_existing_blocking( path: impl AsRef<Path>, ) -> Result<Self, StoreError>

Open an existing database without creating a new file or writing to it; a store in a retired or newer layout is refused unchanged.

Source

pub fn in_memory_blocking() -> Result<Self, StoreError>

Create an isolated in-memory database for ephemeral work and tests.

Source

pub fn path(&self) -> &Path

Database location, or the in-memory label.

Source

pub fn set_busy_timeout_blocking( &self, timeout: Duration, ) -> Result<(), StoreError>

Wait at most timeout for another connection’s lock before failing as busy.

Source

pub fn lineage_blocking(&self) -> Result<Option<StoreLineage>, StoreError>

The lineage this file continues, if initialized.

Source

pub fn revision_blocking(&self) -> Result<Option<StoreRevision>, StoreError>

The committed revision and its lineage, read in one transaction without the snapshot text, so polling for changes costs two row reads; None for an uninitialized store.

Source

pub fn plan_before_blocking(&self, sequence: u64) -> Result<Plan, StoreError>

The plan as it stood before the operation at local sequence sequence, replayed from the genesis plan; a resent plan change is compared against the state it was first applied to.

Source

pub fn load_blocking(&self) -> Result<Option<Plan>, StoreError>

Read and validate the authoritative snapshot, if initialized.

Source

pub fn initialize_blocking(&mut self, plan: &Plan) -> Result<(), StoreError>

Initialize an empty database with plan as both the snapshot and the genesis plan the history replays from; an existing snapshot or operation history is never erased, and a refused initialization writes nothing.

Source

pub fn persist_blocking( &mut self, plan: &Plan, operation: &Operation, expected_lineage: Option<LineageId>, ) -> Result<HistoryEntry, StoreError>

Atomically append one valid operation and the exact snapshot produced by that command, under this file’s lineage.

Inside the write transaction, an identity that is already recorded is answered with StoreError::DuplicateOperation before any precondition, an archive is refused, and so is a lineage other than expected_lineage or a revision other than the operation’s base.

Source

pub fn operation_count_blocking(&self) -> Result<u64, StoreError>

Count committed semantic operations.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more