Skip to main content

SqliteMemory

Struct SqliteMemory 

Source
pub struct SqliteMemory<E: Embedder> { /* private fields */ }
Expand description

SQLite-backed memory store with optional embedding support.

Implementations§

Source§

impl<E: Embedder> SqliteMemory<E>

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open or create a SQLite database at the given path.

Source

pub fn in_memory() -> Result<Self>

Create an in-memory database (useful for testing).

Source

pub fn with_embedder(self, embedder: E) -> Self

Attach an embedder for vector search.

Source

pub fn store_with_metadata( &self, key: &str, value: &str, metadata: Option<&Value>, embedding: Option<&[f32]>, ) -> Result<()>

Store a key-value pair with optional metadata and embedding.

Source

pub fn get_entry(&self, key: &str) -> Option<MemoryEntry>

Get a full MemoryEntry for a key.

Trait Implementations§

Source§

impl<E: Embedder> Memory for SqliteMemory<E>

Source§

fn get(&self, key: &str) -> Option<String>

Get the value for a key (owned).
Source§

fn entries(&self) -> Vec<(String, String)>

Get all key-value pairs (owned).
Source§

fn set( &self, key: impl Into<String>, value: impl Into<String>, ) -> Option<String>

Set (upsert) a key-value pair. Returns the previous value if the key existed.
Source§

fn remove(&self, key: &str) -> Option<String>

Remove a key. Returns the removed value if it existed.
Source§

fn store( &self, key: impl Into<String> + Send, value: impl Into<String> + Send, ) -> impl Future<Output = Result<()>> + Send

Store a key-value pair (async). Default delegates to set.
Source§

fn recall( &self, query: &str, options: RecallOptions, ) -> impl Future<Output = Result<Vec<MemoryEntry>>> + Send

Search for relevant entries (async). Default returns empty.
Source§

fn compile_relevant(&self, query: &str) -> impl Future<Output = String> + Send

Compile relevant entries for a query (async). Default delegates to compile.
Source§

fn compile(&self) -> String

Compile memory into a string for system prompt injection. Read more

Auto Trait Implementations§

§

impl<E> !Freeze for SqliteMemory<E>

§

impl<E> RefUnwindSafe for SqliteMemory<E>
where E: RefUnwindSafe,

§

impl<E> Send for SqliteMemory<E>

§

impl<E> Sync for SqliteMemory<E>

§

impl<E> Unpin for SqliteMemory<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for SqliteMemory<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for SqliteMemory<E>
where E: UnwindSafe,

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.