pub struct Sql { /* private fields */ }Expand description
The SQLite store: a writer connection used under the store’s write lock, a reader for searches and audit queries, and a checkpointer thread.
Implementations§
Source§impl Sql
impl Sql
Sourcepub fn open(path: impl Into<PathBuf>) -> Result<Sql>
pub fn open(path: impl Into<PathBuf>) -> Result<Sql>
Open (or create) the store file at path, requiring the current schema, with
Durability::Full.
Sourcepub fn open_with(
path: impl Into<PathBuf>,
durability: Durability,
) -> Result<Sql>
pub fn open_with( path: impl Into<PathBuf>, durability: Durability, ) -> Result<Sql>
Sql::open at a chosen Durability.
pub fn path(&self) -> &Path
Sourcepub fn synchronous(&self) -> Result<i64>
pub fn synchronous(&self) -> Result<i64>
The writer connection’s PRAGMA synchronous: 2 is FULL, 1 NORMAL.
Sourcepub fn set_meta(&self, key: &str, value: &str) -> Result<()>
pub fn set_meta(&self, key: &str, value: &str) -> Result<()>
Set a meta value outside any change (start-up bookkeeping).
Sourcepub fn load(&self) -> Result<Option<State>>
pub fn load(&self) -> Result<Option<State>>
The whole state, or None for a store nothing has been written to.
Sourcepub fn write(
&self,
change: &Change<'_>,
events: Vec<AuditEvent>,
) -> Result<Vec<AuditEvent>>
pub fn write( &self, change: &Change<'_>, events: Vec<AuditEvent>, ) -> Result<Vec<AuditEvent>>
Write one change in ONE transaction: the state fields that moved, the
parts that moved, the search index for them, and the change’s audit
events. Either all of it is on disk when this returns Ok, or none of
it is. The events come back numbered.
Sourcepub fn candidates(&self, query: &Candidates<'_>) -> Result<Vec<(i64, String)>>
pub fn candidates(&self, query: &Candidates<'_>) -> Result<Vec<(i64, String)>>
Every part whose number, name, description, category, tags,
attribute values, MPNs or SPNs contain needle as a substring (at
least three characters, ignoring case) — the FTS5 trigram index —
together with the indexed narrowing in query. Creation order, from
after query.after, at most query.limit.
Sourcepub fn checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Fold the write-ahead log into the main file, so the file alone is the whole store (before it is renamed or copied).
Source§impl Sql
impl Sql
Sourcepub fn preferences(
&self,
user_id: &str,
since: u64,
) -> Result<(u64, Vec<PreferenceRow>)>
pub fn preferences( &self, user_id: &str, since: u64, ) -> Result<(u64, Vec<PreferenceRow>)>
A user’s preferences version (0 before their first write) and their
rows: every live key by name when since is 0, else every row — live
or deleted — written after since, oldest first.
Sourcepub fn preference(
&self,
user_id: &str,
key: &str,
) -> Result<Option<(String, u64)>>
pub fn preference( &self, user_id: &str, key: &str, ) -> Result<Option<(String, u64)>>
One live preference’s value and version.
Sourcepub fn set_preference(
&self,
user_id: &str,
key: &str,
value: Option<&str>,
at: u64,
event: Option<AuditEvent>,
) -> Result<u64>
pub fn set_preference( &self, user_id: &str, key: &str, value: Option<&str>, at: u64, event: Option<AuditEvent>, ) -> Result<u64>
Write (Some) or delete (None) one preference, and its audit event
if it has one, in ONE transaction. Returns the user’s version after:
bumped by a write, and by a delete of a live key; a delete of a key
that is not there changes nothing and logs nothing.
Trait Implementations§
Source§impl AuditSink for Sql
impl AuditSink for Sql
Source§fn append(&self, events: Vec<AuditEvent>) -> Result<Vec<AuditEvent>>
fn append(&self, events: Vec<AuditEvent>) -> Result<Vec<AuditEvent>>
events in order, numbering each. Returns them numbered.Source§fn query(&self, filter: &AuditFilter) -> Result<Vec<AuditEvent>>
fn query(&self, filter: &AuditFilter) -> Result<Vec<AuditEvent>>
filter, newest first.Auto Trait Implementations§
impl !Freeze for Sql
impl !RefUnwindSafe for Sql
impl !UnwindSafe for Sql
impl Forget for Sql
impl Move for Sql
impl Send for Sql
impl Sync for Sql
impl Unpin for Sqlwhere
*const u8 is !null: Unpin,
Align4<u32>: Unpin,
Align1<u8>: Unpin,
*mut sqlite3: Unpin,
Arc<Mutex<*mut sqlite3>>: Unpin,
*const Node<Arc<str>, RawStatement> is !null: Unpin,
*mut Counter<Channel<()>>: Unpin,
*mut Counter<Channel<()>>: Unpin,
*mut Counter<Channel<()>>: Unpin,
Arc<Inner, System>: Unpin,
Arc<Packet<'static, ()>>: Unpin,
impl UnsafeUnpin for Sqlwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*mut sqlite3: UnsafeUnpin,
*const ArcInner<Mutex<*mut sqlite3>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<*mut sqlite3>>>: UnsafeUnpin,
PhantomData<NonNull<Node<Arc<str>, RawStatement>>>: UnsafeUnpin,
*const Node<Arc<str>, RawStatement> is !null: UnsafeUnpin,
*mut Counter<Channel<()>>: UnsafeUnpin,
*mut Counter<Channel<()>>: UnsafeUnpin,
*mut Counter<Channel<()>>: UnsafeUnpin,
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
*const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.