Skip to main content

SessionService

Trait SessionService 

Source
pub trait SessionService: Send + Sync {
    // Required methods
    fn create_session<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        app_name: &'life1 str,
        user_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Session, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Session>, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_sessions<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        app_name: &'life1 str,
        user_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete_session<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn append_event<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
        event: Event,
    ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_events<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 SessionId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, SessionError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for session persistence — CRUD operations + event append.

Implementations must be Send + Sync for use across async tasks.

Required Methods§

Source

fn create_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Session, SessionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a new session.

Source

fn get_session<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<Option<Session>, SessionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a session by ID.

Source

fn list_sessions<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, app_name: &'life1 str, user_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Session>, SessionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

List sessions for an app + user.

Source

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

Delete a session.

Source

fn append_event<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 SessionId, event: Event, ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Append an event to a session’s history.

Source

fn get_events<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 SessionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Event>, SessionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all events for a session.

Implementors§