pub struct SqliteStorage { /* private fields */ }Expand description
SQLite-backed implementation of ContextStorage.
Implementations§
Source§impl SqliteStorage
impl SqliteStorage
Sourcepub fn open(db_path: &Path, max_entries: usize) -> Result<Self>
pub fn open(db_path: &Path, max_entries: usize) -> Result<Self>
Open (or create) a SQLite database at db_path and run migrations.
For ":memory:", a single-connection pool is used so that all operations
share the same in-memory database instance.
§Errors
Returns an error if the database cannot be opened, the connection pool cannot be built, or migrations fail.
Sourcepub fn pool(&self) -> Arc<Pool<SqliteConnectionManager>>
pub fn pool(&self) -> Arc<Pool<SqliteConnectionManager>>
Return a reference-counted handle to the connection pool so that
SqliteSearcher can share it.
Sourcepub fn schema_version(&self) -> Result<i64>
pub fn schema_version(&self) -> Result<i64>
Return the current schema version from the database.
§Errors
Returns an error if the connection pool or query fails.
Sourcepub fn checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Run a WAL checkpoint (TRUNCATE mode) to flush the WAL file.
Safe to call at any time; no-op if no WAL pages are pending.
§Errors
Returns an error if the connection pool or checkpoint pragma fails.
Trait Implementations§
Source§impl ContextStorage for SqliteStorage
impl ContextStorage for SqliteStorage
Source§fn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>
fn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>
Return the top-k entries (most recent or highest priority). Read more
Source§fn delete(&self, id: &str) -> Result<bool>
fn delete(&self, id: &str) -> Result<bool>
Delete an entry by id. Returns
true if an entry was removed. Read moreSource§fn clear(&self) -> Result<usize>
fn clear(&self) -> Result<usize>
Remove all entries. Returns the number of entries removed. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteStorage
impl !UnwindSafe for SqliteStorage
impl Freeze for SqliteStorage
impl Send for SqliteStorage
impl Sync for SqliteStorage
impl Unpin for SqliteStorage
impl UnsafeUnpin for SqliteStorage
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
Mutably borrows from an owned value. Read more