pub trait ProjectMemory: Send + Sync {
// Required methods
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn keys<'life0, 'life1, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Project-scoped key-value memory with fuzzy search.
Unlike UserProfileMemory, this layer is designed for larger,
project-associated datasets that benefit from content-based retrieval.
Values are opaque strings and the search method enables approximate
matching (e.g. for notes, code snippets, or documentation fragments).
§Typical backends
- Full-text search index (Tantivy, Meilisearch) backed by a document store.
- Vector database (Qdrant, Milvus) with semantic search via embedding.
- SQLite with FTS5 extension.
§Examples
use xz_memory_engine::layered::traits::ProjectMemory;
use xz_memory_core::StoreError;
async fn example(store: &dyn ProjectMemory) -> Result<(), StoreError> {
store.put("proj-1", "note-1", "Remember to update deps").await?;
let val = store.get("proj-1", "note-1").await?;
assert_eq!(val, Some("Remember to update deps".into()));
let results = store.search("proj-1", "update deps").await?;
assert!(!results.is_empty());
Ok(())
}Required Methods§
Sourcefn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Store a key-value pair in the project namespace.
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Retrieve a value by key.
Returns None if the key does not exist.
Sourcefn keys<'life0, 'life1, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn keys<'life0, 'life1, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List all keys in the project namespace.
Sourcefn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32)>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
project_id: &'life1 str,
query: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32)>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Search for entries matching the query string.
Returns a vector of (key, relevance_score) pairs sorted by
descending relevance. The score is a float typically in [0.0, 1.0]
but the range is backend-defined.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".