Skip to main content

agent_io/memory/
store.rs

1//! Memory store trait
2
3use async_trait::async_trait;
4
5use super::entry::MemoryEntry;
6use crate::Result;
7
8/// Memory store trait for persisting and retrieving memories
9#[async_trait]
10pub trait MemoryStore: Send + Sync {
11    /// Add a memory entry, returns the entry ID
12    async fn add(&self, entry: MemoryEntry) -> Result<String>;
13
14    /// Search memories by text query
15    async fn search(&self, query: &str, limit: usize) -> Result<Vec<MemoryEntry>>;
16
17    /// Search memories by embedding similarity
18    async fn search_by_embedding(
19        &self,
20        embedding: &[f32],
21        limit: usize,
22        threshold: f32,
23    ) -> Result<Vec<MemoryEntry>>;
24
25    /// Get a memory by ID
26    async fn get(&self, id: &str) -> Result<Option<MemoryEntry>>;
27
28    /// Update a memory entry
29    async fn update(&self, entry: MemoryEntry) -> Result<()>;
30
31    /// Delete a memory by ID
32    async fn delete(&self, id: &str) -> Result<()>;
33
34    /// Clear all memories
35    async fn clear(&self) -> Result<()>;
36
37    /// Get total count of memories
38    async fn count(&self) -> Result<usize>;
39
40    /// Get all memory IDs
41    async fn ids(&self) -> Result<Vec<String>>;
42}