Skip to main content

SqliteStore

Struct SqliteStore 

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

An open store: its connection and the file it reads, when not in memory.

Implementations§

Source§

impl SqliteStore

Source

pub fn open(file: Option<&Path>, schema: &'static str, version: i32) -> Self

Open file (None: in memory) with schema (its statements idempotent) at schema version. A file that cannot be opened, or holds another version, is reported (Warning) and left alone; the store is then in memory.

Source

pub fn file(&self) -> Option<&Path>

The file the store reads, None in memory.

Source

pub fn fell_back(&self) -> bool

Whether a file was asked for and could not be used, so the store may not know what earlier runs stored there.

Source

pub fn wants_file(&self) -> bool

Whether a file was asked for: the store runs on it, or in memory in its place.

Source

pub fn immediate<T>( &mut self, f: impl FnMut(&Transaction<'_>, bool) -> Result<T>, ) -> Option<T>

Run f in one IMMEDIATE transaction, committed when it succeeds. A file that fails is reported (Warning) and replaced by memory (attempt, from copy), where f runs again: f is told whether the store runs in memory in place of its file (Self::fell_back), and defers its own side effects (a Warning) until the call returns. A transaction that fails in a fresh store in memory is reported (Error) and gives None.

Source

pub fn read<T>(&mut self, f: impl Fn(&Connection) -> Result<T>) -> Option<T>

A read outside any transaction, under Self::immediate’s failure policy.

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, 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.