Skip to main content

MemoryStore

Trait MemoryStore 

Source
pub trait MemoryStore: Send + Sync {
    // Required methods
    fn store<'life0, 'async_trait>(
        &'life0 self,
        item: MemoryItem,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retrieve<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryItem>>> + 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<MemoryItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search_by_tags<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tags: &'life1 [String],
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_recent<'life0, 'async_trait>(
        &'life0 self,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_important<'life0, 'async_trait>(
        &'life0 self,
        threshold: f32,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'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;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn store_and_return<'life0, 'async_trait>(
        &'life0 self,
        item: MemoryItem,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryItem>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn prune<'life0, 'life1, 'async_trait>(
        &'life0 self,
        policy: &'life1 PrunePolicy,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Required Methods§

Source

fn store<'life0, 'async_trait>( &'life0 self, item: MemoryItem, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

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

Source

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

Source

fn search_by_tags<'life0, 'life1, 'async_trait>( &'life0 self, tags: &'life1 [String], limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn get_recent<'life0, 'async_trait>( &'life0 self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_important<'life0, 'async_trait>( &'life0 self, threshold: f32, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn delete<'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,

Source

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

Source

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

Provided Methods§

Source

fn store_and_return<'life0, 'async_trait>( &'life0 self, item: MemoryItem, ) -> Pin<Box<dyn Future<Output = Result<MemoryItem>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a memory and return the canonical item that now represents it.

Default stores may merge durable duplicate content into an existing item and return that existing item with updated metadata. Custom backends that do not implement deduplication can rely on this default wrapper.

Source

fn prune<'life0, 'life1, 'async_trait>( &'life0 self, policy: &'life1 PrunePolicy, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove stale or excess items according to policy.

Returns the number of items deleted. The default implementation is a no-op (returns 0) for backwards compatibility.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§