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§
Required Methods§
Sourcefn get_sessions(
&mut self,
) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send
fn get_sessions( &mut self, ) -> impl Future<Output = Result<Vec<String>, Self::Error>> + Send
Returns a list of available session IDs
Sourcefn get_session_age(
&mut self,
session_id: &str,
) -> impl Future<Output = Result<Option<u64>, Self::Error>> + Send
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
Sourcefn remove_session(
&mut self,
session_id: &str,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn remove_session( &mut self, session_id: &str, ) -> impl Future<Output = Result<(), Self::Error>> + Send
Sourcefn read_value(
&mut self,
session_id: &str,
key: &str,
) -> impl Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send
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
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.