pub trait SessionManagerTrait: Send + Sync {
Show 13 methods
// Required methods
fn create<'life0, 'async_trait>(
&'life0 self,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_or_create<'life0, 'life1, 'async_trait>(
&'life0 self,
id: Option<&'life1 SessionId>,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 Session,
) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer2Result<Vec<SessionMeta>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
id: &'life1 SessionId,
update_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where F: FnOnce(&mut Session) + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn read<'life0, 'life1, 'async_trait, F, T>(
&'life0 self,
id: &'life1 SessionId,
read_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<T>>> + Send + 'async_trait>>
where F: FnOnce(&Session) -> T + Send + 'async_trait,
T: Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<AgentState>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
state: AgentState,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn add_message<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
message: Message,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Vec<Message>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn stats(&self) -> SessionStats;
}Expand description
会话管理器接口
定义会话生命周期的核心操作。
Required Methods§
Sourcefn create<'life0, 'async_trait>(
&'life0 self,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn get_or_create<'life0, 'life1, 'async_trait>(
&'life0 self,
id: Option<&'life1 SessionId>,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_or_create<'life0, 'life1, 'async_trait>(
&'life0 self,
id: Option<&'life1 SessionId>,
config: SessionConfig,
) -> Pin<Box<dyn Future<Output = Layer2Result<SessionId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 Session,
) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 Session,
) -> Pin<Box<dyn Future<Output = Layer2Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer2Result<Vec<SessionMeta>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Layer2Result<Vec<SessionMeta>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn update<'life0, 'life1, 'async_trait, F>(
&'life0 self,
id: &'life1 SessionId,
update_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
fn update<'life0, 'life1, 'async_trait, F>( &'life0 self, id: &'life1 SessionId, update_fn: F, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
Sourcefn read<'life0, 'life1, 'async_trait, F, T>(
&'life0 self,
id: &'life1 SessionId,
read_fn: F,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<T>>> + Send + 'async_trait>>
fn read<'life0, 'life1, 'async_trait, F, T>( &'life0 self, id: &'life1 SessionId, read_fn: F, ) -> Pin<Box<dyn Future<Output = Layer2Result<Option<T>>> + Send + 'async_trait>>
Sourcefn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<AgentState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<AgentState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取会话状态
Sourcefn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
state: AgentState,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
state: AgentState,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
设置会话状态
Sourcefn add_message<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
message: Message,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_message<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
message: Message,
) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
添加消息到会话
Sourcefn get_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Vec<Message>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Layer2Result<Option<Vec<Message>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取会话消息列表
Sourcefn stats(&self) -> SessionStats
fn stats(&self) -> SessionStats
获取统计信息
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".