Skip to main content

Store

Trait Store 

Source
pub trait Store: Send + Sync {
    // Required methods
    fn put<'a>(
        &'a self,
        namespace: &'a [&'a str],
        key: &'a str,
        value: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'a>>;
    fn get<'a>(
        &'a self,
        namespace: &'a [&'a str],
        key: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StoreItem>, ReactError>> + Send + 'a>>;
    fn search<'a>(
        &'a self,
        namespace: &'a [&'a str],
        query: &'a str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>;
    fn delete<'a>(
        &'a self,
        namespace: &'a [&'a str],
        key: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, ReactError>> + Send + 'a>>;
    fn list_namespaces<'a>(
        &'a self,
        prefix: Option<&'a [&'a str]>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<String>>, ReactError>> + Send + 'a>>;
    fn list<'a>(
        &'a self,
        namespace: &'a [&'a str],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>;

    // Provided method
    fn search_with<'a>(
        &'a self,
        namespace: &'a [&'a str],
        query: SearchQuery<'a>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>> { ... }
}
Expand description

Unified storage interface for long-term memory

Required Methods§

Source

fn put<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, value: Value, ) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'a>>

Write or update a record (upsert)

Source

fn get<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<StoreItem>, ReactError>> + Send + 'a>>

Exact fetch by key

Source

fn search<'a>( &'a self, namespace: &'a [&'a str], query: &'a str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>

Keyword search, returns at most limit items (sorted by relevance)

Source

fn delete<'a>( &'a self, namespace: &'a [&'a str], key: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, ReactError>> + Send + 'a>>

Delete the specified key, returns whether it existed and was deleted

Source

fn list_namespaces<'a>( &'a self, prefix: Option<&'a [&'a str]>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<String>>, ReactError>> + Send + 'a>>

List all namespaces matching the given prefix

Source

fn list<'a>( &'a self, namespace: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>

List all entries in the namespace (no keyword filter, no pagination limit).

Provided Methods§

Source

fn search_with<'a>( &'a self, namespace: &'a [&'a str], query: SearchQuery<'a>, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoreItem>, ReactError>> + Send + 'a>>

Unified search entry point.

By default only supports keyword search; semantic/hybrid search must be explicitly overridden by concrete implementations.

Implementors§