pub trait SessionStore:
Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn get<T>(
&self,
session_id: &Id,
field: &str,
) -> impl Future<Output = Result<Option<T>, Error>> + Send
where T: Send + Sync + DeserializeOwned;
fn get_all(
&self,
session_id: &Id,
) -> impl Future<Output = Result<Option<SessionMap>, Error>> + Send;
fn insert<T>(
&self,
session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
where T: Send + Sync + Serialize + 'static;
fn update<T>(
&self,
session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
where T: Send + Sync + Serialize + 'static;
fn insert_with_rename<T>(
&self,
old_session_id: &Id,
new_session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
where T: Send + Sync + Serialize + 'static;
fn update_with_rename<T>(
&self,
old_session_id: &Id,
new_session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
where T: Send + Sync + Serialize + 'static;
fn rename_session_id(
&self,
old_session_id: &Id,
new_session_id: &Id,
) -> impl Future<Output = Result<bool, Error>> + Send;
fn remove(
&self,
session_id: &Id,
field: &str,
) -> impl Future<Output = Result<i64, Error>> + Send;
fn delete(
&self,
session_id: &Id,
) -> impl Future<Output = Result<bool, Error>> + Send;
fn expire(
&self,
session_id: &Id,
ttl_secs: i64,
) -> impl Future<Output = Result<bool, Error>> + Send;
}Required Methods§
Sourcefn get<T>(
&self,
session_id: &Id,
field: &str,
) -> impl Future<Output = Result<Option<T>, Error>> + Send
fn get<T>( &self, session_id: &Id, field: &str, ) -> impl Future<Output = Result<Option<T>, Error>> + Send
Gets the value for a field stored at session_id
Sourcefn get_all(
&self,
session_id: &Id,
) -> impl Future<Output = Result<Option<SessionMap>, Error>> + Send
fn get_all( &self, session_id: &Id, ) -> impl Future<Output = Result<Option<SessionMap>, Error>> + Send
Gets all the field-value pairs stored at session_id
Sourcefn insert<T>(
&self,
session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
fn insert<T>( &self, session_id: &Id, field: &str, value: &T, key_ttl_secs: Option<i64>, field_ttl_secs: Option<i64>, _: Option<PhantomData<()>>, ) -> impl Future<Output = Result<i64, Error>> + Send
Sets a field stored at session_id to its provided value,
only if the field does not exist.
Returns the new max_age of the session if the field was inserted, otherwise, None.
Sourcefn update<T>(
&self,
session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
fn update<T>( &self, session_id: &Id, field: &str, value: &T, key_ttl_secs: Option<i64>, field_ttl_secs: Option<i64>, _: Option<PhantomData<()>>, ) -> impl Future<Output = Result<i64, Error>> + Send
Updates a field stored at session_id to the new value.
If the field does not exist, it is set to the corresponding value.
Returns the new max_age of the session if the field was updated.
Sourcefn insert_with_rename<T>(
&self,
old_session_id: &Id,
new_session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
fn insert_with_rename<T>( &self, old_session_id: &Id, new_session_id: &Id, field: &str, value: &T, key_ttl_secs: Option<i64>, field_ttl_secs: Option<i64>, _: Option<PhantomData<()>>, ) -> impl Future<Output = Result<i64, Error>> + Send
Sets a field stored at session_id to its provided value and renames
the session ID from old_session_id to new_session_id,
only if the field does not exist.
Returns the new max_age of the session if the field was inserted, otherwise, None.
Sourcefn update_with_rename<T>(
&self,
old_session_id: &Id,
new_session_id: &Id,
field: &str,
value: &T,
key_ttl_secs: Option<i64>,
field_ttl_secs: Option<i64>,
_: Option<PhantomData<()>>,
) -> impl Future<Output = Result<i64, Error>> + Send
fn update_with_rename<T>( &self, old_session_id: &Id, new_session_id: &Id, field: &str, value: &T, key_ttl_secs: Option<i64>, field_ttl_secs: Option<i64>, _: Option<PhantomData<()>>, ) -> impl Future<Output = Result<i64, Error>> + Send
Updates a field stored at session_id to the new value and renames
the session ID from old_session_id to new_session_id.
If the field does not exist, it is set to the corresponding value.
Returns the new max_age of the session if the field was updated.
Sourcefn rename_session_id(
&self,
old_session_id: &Id,
new_session_id: &Id,
) -> impl Future<Output = Result<bool, Error>> + Send
fn rename_session_id( &self, old_session_id: &Id, new_session_id: &Id, ) -> impl Future<Output = Result<bool, Error>> + Send
Renames the old_session_id to new_session_id if the old_session_id exists.
Returns an error when old_session_id does not exist.
Sourcefn remove(
&self,
session_id: &Id,
field: &str,
) -> impl Future<Output = Result<i64, Error>> + Send
fn remove( &self, session_id: &Id, field: &str, ) -> impl Future<Output = Result<i64, Error>> + Send
Remove the field along with its value stored at session_id.
Returns the TTL of the entire session stored at session_id.
- -1 if the session is persistent.
- > 0
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.