pub trait SessionStore: Send + Sync {
// Required methods
fn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ChatSession>, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn get_user_sessions<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatSession>, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn update_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn delete_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<bool, PersistenceError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
会话存储 trait
提供聊天会话的管理
Required Methods§
Sourcefn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn create_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
创建会话
Sourcefn get_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ChatSession>, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ChatSession>, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取会话
Sourcefn get_user_sessions<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatSession>, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn get_user_sessions<'life0, 'async_trait>(
&'life0 self,
user_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<ChatSession>, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
获取用户会话列表
Sourcefn update_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn update_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 ChatSession,
) -> Pin<Box<dyn Future<Output = Result<(), PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
更新会话
Sourcefn delete_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<bool, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn delete_session<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<bool, PersistenceError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
删除会话