SessionStore

Trait SessionStore 

Source
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§

Source

fn get<T>( &self, session_id: &Id, field: &str, ) -> impl Future<Output = Result<Option<T>, Error>> + Send
where T: Send + Sync + DeserializeOwned,

Gets the value for a field stored at session_id

Source

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

Source

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,

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.

Source

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,

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.

Source

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,

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.

Source

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,

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.

Source

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.

Source

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
Source

fn delete( &self, session_id: &Id, ) -> impl Future<Output = Result<bool, Error>> + Send

Deletes all fields along with its values stored in the session_id.

Source

fn expire( &self, session_id: &Id, ttl_secs: i64, ) -> impl Future<Output = Result<bool, Error>> + Send

Set a timeout on the session_id. After the timeout has expired, the session_id will be automatically deleted.

A value of -1 or 0 immediately expires the session_id.

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§