Skip to main content

MemoryProvider

Trait MemoryProvider 

Source
pub trait MemoryProvider: Send + Sync {
    // Required methods
    fn store<'life0, 'life1, 'async_trait>(
        &'life0 self,
        content: &'life1 str,
        metadata: MemoryMetadata,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn forget<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Abstraction over long-term memory storage and retrieval.

Implementations back the memory_store / memory_recall tools. Returned IDs are opaque strings; callers must store them if they need to call forget.

Required Methods§

Source

fn store<'life0, 'life1, 'async_trait>( &'life0 self, content: &'life1 str, metadata: MemoryMetadata, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist content with metadata. Returns the new entry’s ID.

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Semantic search. Returns up to limit entries ordered by descending relevance.

Source

fn forget<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a specific entry by ID. No-op if the ID does not exist.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§