Trait SessionStore

Source
pub trait SessionStore: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = Option<Arc<Mutex<TxServer>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'async_trait>(
        &'life0 self,
        key: SessionId,
        value: TxServer,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn keys<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<SessionId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn values<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<Arc<Mutex<DuplexStream>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait defining the interface for session storage operations

This trait provides asynchronous methods for managing session data, Implementors must be Send and Sync to support concurrent access.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Option<Arc<Mutex<TxServer>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a session by its identifier

§Arguments
  • key - The session identifier to look up
§Returns
  • Option<Arc<Mutex<TxServer>>> - The session stream wrapped in Arc<Mutex> if found, None otherwise
Source

fn set<'life0, 'async_trait>( &'life0 self, key: SessionId, value: TxServer, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stores a new session with the given identifier

§Arguments
  • key - The session identifier
  • value - The duplex stream to store
Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a session by its identifier

§Arguments
  • key - The session identifier to delete
Source

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

Clears all sessions from the store

Source

fn keys<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<SessionId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn values<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<Arc<Mutex<DuplexStream>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§

Source§

impl SessionStore for InMemorySessionStore

Implementation of the SessionStore trait for InMemorySessionStore

Provides asynchronous methods for managing sessions in memory, ensuring thread-safety through read-write locks and mutexes.