pub trait MemorySystem: Send + Sync {
// Required methods
fn store<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
content: String,
) -> Pin<Box<dyn Future<Output = Layer3Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn query_all<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
) -> Pin<Box<dyn Future<Output = Layer3Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<HashMap<MemoryTier, usize>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
记忆系统 trait
统一管理所有记忆层级的接口。
Required Methods§
Sourcefn store<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
content: String,
) -> Pin<Box<dyn Future<Output = Layer3Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
content: String,
) -> Pin<Box<dyn Future<Output = Layer3Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
存储记忆到指定层级
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<Option<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
从指定层级获取记忆
Sourcefn query_all<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_all<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
跨层级查询记忆
默认从 Working -> Session -> Project -> LongTerm 依次查询
Sourcefn query<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
query: &'life1 MemoryQuery,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
在指定层级查询
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
tier: MemoryTier,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Layer3Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
删除指定层级记忆
Sourcefn clear<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
) -> Pin<Box<dyn Future<Output = Layer3Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
tier: MemoryTier,
) -> Pin<Box<dyn Future<Output = Layer3Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
清空指定层级
Sourcefn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<HashMap<MemoryTier, usize>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer3Result<HashMap<MemoryTier, usize>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取层级统计
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl MemorySystem for UnifiedMemorySystem
MemorySystem trait 实现