pub struct MemoryManager { /* private fields */ }Expand description
High-level memory manager that coordinates database, embeddings, and chunking
Implementations§
Source§impl MemoryManager
impl MemoryManager
pub fn db(&self) -> &Arc<MemoryDatabase>
Sourcepub async fn new(db_path: &Path) -> MemoryResult<Self>
pub async fn new(db_path: &Path) -> MemoryResult<Self>
Initialize the memory manager
Sourcepub async fn store_message(
&self,
request: StoreMessageRequest,
) -> MemoryResult<Vec<String>>
pub async fn store_message( &self, request: StoreMessageRequest, ) -> MemoryResult<Vec<String>>
Store a message in memory
This will:
- Chunk the message content
- Generate embeddings for each chunk
- Store chunks and embeddings in the database
Sourcepub async fn search(
&self,
query: &str,
tier: Option<MemoryTier>,
project_id: Option<&str>,
session_id: Option<&str>,
limit: Option<i64>,
) -> MemoryResult<Vec<MemorySearchResult>>
pub async fn search( &self, query: &str, tier: Option<MemoryTier>, project_id: Option<&str>, session_id: Option<&str>, limit: Option<i64>, ) -> MemoryResult<Vec<MemorySearchResult>>
Search memory for relevant chunks
Sourcepub async fn retrieve_context(
&self,
query: &str,
project_id: Option<&str>,
session_id: Option<&str>,
token_budget: Option<i64>,
) -> MemoryResult<MemoryContext>
pub async fn retrieve_context( &self, query: &str, project_id: Option<&str>, session_id: Option<&str>, token_budget: Option<i64>, ) -> MemoryResult<MemoryContext>
Retrieve context for a message
This retrieves relevant chunks from all tiers and formats them for injection into the prompt
Sourcepub async fn retrieve_context_with_meta(
&self,
query: &str,
project_id: Option<&str>,
session_id: Option<&str>,
token_budget: Option<i64>,
) -> MemoryResult<(MemoryContext, MemoryRetrievalMeta)>
pub async fn retrieve_context_with_meta( &self, query: &str, project_id: Option<&str>, session_id: Option<&str>, token_budget: Option<i64>, ) -> MemoryResult<(MemoryContext, MemoryRetrievalMeta)>
Retrieve context plus retrieval metadata for observability.
Sourcepub async fn clear_session(&self, session_id: &str) -> MemoryResult<u64>
pub async fn clear_session(&self, session_id: &str) -> MemoryResult<u64>
Clear session memory
Sourcepub async fn clear_project(&self, project_id: &str) -> MemoryResult<u64>
pub async fn clear_project(&self, project_id: &str) -> MemoryResult<u64>
Clear project memory
Sourcepub async fn get_stats(&self) -> MemoryResult<MemoryStats>
pub async fn get_stats(&self) -> MemoryResult<MemoryStats>
Get memory statistics
Sourcepub async fn get_config(&self, project_id: &str) -> MemoryResult<MemoryConfig>
pub async fn get_config(&self, project_id: &str) -> MemoryResult<MemoryConfig>
Get memory configuration for a project
Sourcepub async fn set_config(
&self,
project_id: &str,
config: &MemoryConfig,
) -> MemoryResult<()>
pub async fn set_config( &self, project_id: &str, config: &MemoryConfig, ) -> MemoryResult<()>
Update memory configuration for a project
Sourcepub async fn run_cleanup(&self, project_id: Option<&str>) -> MemoryResult<u64>
pub async fn run_cleanup(&self, project_id: Option<&str>) -> MemoryResult<u64>
Run cleanup based on retention policies
Sourcepub async fn get_cleanup_log(
&self,
_limit: i64,
) -> MemoryResult<Vec<CleanupLogEntry>>
pub async fn get_cleanup_log( &self, _limit: i64, ) -> MemoryResult<Vec<CleanupLogEntry>>
Get cleanup log entries
Sourcepub fn count_tokens(&self, text: &str) -> usize
pub fn count_tokens(&self, text: &str) -> usize
Count tokens in text
Sourcepub async fn embedding_health(&self) -> EmbeddingHealth
pub async fn embedding_health(&self) -> EmbeddingHealth
Report embedding backend health for UI/telemetry.
Sourcepub async fn consolidate_session(
&self,
session_id: &str,
project_id: Option<&str>,
providers: &ProviderRegistry,
config: &MemoryConsolidationConfig,
) -> MemoryResult<Option<String>>
pub async fn consolidate_session( &self, session_id: &str, project_id: Option<&str>, providers: &ProviderRegistry, config: &MemoryConsolidationConfig, ) -> MemoryResult<Option<String>>
Consolidate a session’s memory into a summary chunk using the cheapest available provider.
Auto Trait Implementations§
impl Freeze for MemoryManager
impl !RefUnwindSafe for MemoryManager
impl Send for MemoryManager
impl Sync for MemoryManager
impl Unpin for MemoryManager
impl UnsafeUnpin for MemoryManager
impl !UnwindSafe for MemoryManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more