Skip to main content

SqliteStorage

Struct SqliteStorage 

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

SQLite-backed implementation of ContextStorage.

Implementations§

Source§

impl SqliteStorage

Source

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.

Source

pub fn pool(&self) -> Arc<Pool<SqliteConnectionManager>>

Return a reference-counted handle to the connection pool so that SqliteSearcher can share it.

Source

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.

Source

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

Source§

fn save(&self, entry: &ContextEntry) -> Result<()>

Persist a single entry. Read more
Source§

fn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>

Return the top-k entries (most recent or highest priority). Read more
Source§

fn get_all(&self) -> Result<Vec<ContextEntry>>

Return every stored entry. Read more
Source§

fn delete(&self, id: &str) -> Result<bool>

Delete an entry by id. Returns true if an entry was removed. Read more
Source§

fn clear(&self) -> Result<usize>

Remove all entries. Returns the number of entries removed. Read more
Source§

fn clear_scope(&self, scope: &str) -> Result<usize>

Remove all entries within a given scope. Returns the number of entries removed. Read more
Source§

fn count(&self) -> Result<usize>

Return the total number of stored entries. Read more

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