SessionRepository

Trait SessionRepository 

Source
pub trait SessionRepository<DB: Database>: DatabaseRepository<DB> {
    // Required methods
    fn create_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        session: &'life1 DbUserSession,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_session_by_token<'life0, 'life1, 'async_trait>(
        &'life0 self,
        token: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<DbUserSession>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_session_last_accessed<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_session<'life0, 'async_trait>(
        &'life0 self,
        session_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cleanup_expired_sessions<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<i64, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_api_usage<'life0, 'life1, 'async_trait>(
        &'life0 self,
        usage: &'life1 DbApiUsage,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_api_usage_stats<'life0, 'async_trait>(
        &'life0 self,
        from: DateTime<Utc>,
        to: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DbApiUsage>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

用户会话数据库仓库

Required Methods§

Source

fn create_session<'life0, 'life1, 'async_trait>( &'life0 self, session: &'life1 DbUserSession, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

创建用户会话

Source

fn get_session_by_token<'life0, 'life1, 'async_trait>( &'life0 self, token: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DbUserSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

根据令牌获取会话

Source

fn update_session_last_accessed<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

更新会话最后访问时间

Source

fn delete_session<'life0, 'async_trait>( &'life0 self, session_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

删除会话

Source

fn cleanup_expired_sessions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<i64, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

清理过期会话

Source

fn record_api_usage<'life0, 'life1, 'async_trait>( &'life0 self, usage: &'life1 DbApiUsage, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

记录API使用

Source

fn get_api_usage_stats<'life0, 'async_trait>( &'life0 self, from: DateTime<Utc>, to: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Vec<DbApiUsage>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取API使用统计

Implementors§