Trait carapax::session::backend::SessionBackend

source ·
pub trait SessionBackend {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn get_sessions(
        &mut self
    ) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send;
    fn get_session_age(
        &mut self,
        session_id: &str
    ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send;
    fn remove_session(
        &mut self,
        session_id: &str
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn read_value(
        &mut self,
        session_id: &str,
        key: &str
    ) -> impl Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send;
    fn write_value(
        &mut self,
        session_id: &str,
        key: &str,
        value: &[u8]
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn remove_value(
        &mut self,
        session_id: &str,
        key: &str
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Available on crate feature session only.
Expand description

A session backend interface

Required Associated Types§

source

type Error: Error + Send + Sync + 'static

An error occurred in backend

Required Methods§

source

fn get_sessions( &mut self ) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send

Returns a list of available session IDs

source

fn get_session_age( &mut self, session_id: &str ) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send

Returns the time when session was created in seconds

This method MUST return session age if session exists and None otherwise

§Arguments
  • session_id - ID of a session
source

fn remove_session( &mut self, session_id: &str ) -> impl Future<Output = Result<(), Self::Error>> + Send

Removes a session

§Arguments
  • session_id - ID of a session
source

fn read_value( &mut self, session_id: &str, key: &str ) -> impl Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send

Read a value from store

  • session_id - ID of a session
  • key - Key to read value from
source

fn write_value( &mut self, session_id: &str, key: &str, value: &[u8] ) -> impl Future<Output = Result<(), Self::Error>> + Send

Write a value to store

§Arguments
  • session_id - ID of a session
  • key - Key to write value to
  • value - Value to write
source

fn remove_value( &mut self, session_id: &str, key: &str ) -> impl Future<Output = Result<(), Self::Error>> + Send

Remove a value from store

  • session_id - ID of a session
  • key - Key to read value from

Object Safety§

This trait is not object safe.

Implementors§