Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§