pub trait Memory: Send + Sync {
// Required method
fn search<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn add<'life0, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn supports_project_scoping(&self) -> bool { ... }
fn search_in_project<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
project_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn add_to_project<'life0, 'life1, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Semantic memory search for agents.
Required Methods§
Provided Methods§
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Verify backend connectivity.
The default implementation succeeds, which is suitable for in-memory implementations and adapters without an external dependency.
Sourcefn add<'life0, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add<'life0, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a single memory entry.
The default implementation returns an “not implemented” error, which is suitable for read-only memory backends.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete entries matching a query. Returns count of deleted entries.
The default implementation returns an “not implemented” error, which is suitable for read-only memory backends.
Sourcefn supports_project_scoping(&self) -> bool
fn supports_project_scoping(&self) -> bool
Whether this memory keeps project-scoped entries isolated.
Returns false by default, so a caller can tell real isolation apart from a
memory that has no project support instead of inferring it from data.
Sourcefn search_in_project<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
project_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_in_project<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
project_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Searches memories within a specific project.
§Errors
The default implementation returns an error. Delegating to the global search would return entries the project boundary is meant to exclude, and nothing in the result would say the boundary was ignored.
Sourcefn add_to_project<'life0, 'life1, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_to_project<'life0, 'life1, 'async_trait>(
&'life0 self,
entry: MemoryEntry,
project_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Adds a memory entry scoped to a specific project.
§Errors
Returns an error by default. Writing the entry globally would make data intended for one project visible everywhere under the same app and user.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".