pub async fn tap<T: DeserializeOwned>(
        &self,
        func: impl FnOnce(&mut AxumSessionData) -> Option<T>,
    ) -> Option<T> {
        let store_rg = self.store.inner.read().await;

        if let Some(v) = store_rg.get(&self.id.0.to_string()) {
            let mut instance = v.lock().await;
            func(&mut instance)
        } else {
            tracing::warn!("Session data unexpectedly missing");
            None
        }
    }
/// Runs a Closure upon the Current Sessions stored data to get or set session data.
///
/// Provides an Option<T> that returns the requested data from the Sessions store.
///
/// # Examples
/// ```rust no_run
/// session.tap(|sess| {
///   let string = sess.data.get(key)?;
///   serde_json::from_str(string).ok()
/// }).await;
/// ```
///
Runs a Closure upon the Current Sessions stored data to get or set session data.
Provides an Option that returns the requested data from the Sessions store.
Runs a Closure upon the Current Sessions stored data to get or set session data . Provides an Option that returns the requested data from the Sessions store .
pub async fn tap<T: DeserializeOwned>(
        &self,
        func: impl FnOnce(&mut AxumSessionData) -> Option<T>,
    ) -> Option<T> {
        let store_rg = self.store.inner.read().await;
        if let Some(v) = store_rg.get(&self.id.0.to_string()) {
            let mut instance = v.lock().await;
            func(&mut instance)
        } else {
            tracing::warn!("Session data unexpectedly missing");
            None
        }
    }
pub async fn tap < T : DeserializeOwned > ( & self , func : impl FnOnce ( & mut AxumSessionData ) -> Option < T > , ) -> Option < T > { let store_rg = self . store . inner . read ( ) . await ; if let Some ( v ) = store_rg . get ( & self . id . 0 . to_string ( ) ) { let mut instance = v . lock ( ) . await ; func ( & mut instance ) } else { tracing :: warn ! ( " " ) ; None } }
Runs a Closure upon the Current Sessions stored data to get or set session data.
Runs a Closure upon the Current Sessions stored data to get or set session data .
&self
func
impl FnOnce(&mut AxumSessionData) -> Option<T>
&self
func
impl FnOnce(&mut AxumSessionData) -> Option<T>
examples
```rust no_run
session.tap(|sess| {
let string = sess.data.get(key)?;
serde_json::from_str(string).ok()
}).await;
```
` ` ` rust no_run session . tap ( |sess| { let string = sess . data . get ( key ) ? ; serde_json :: from_str ( string ) . ok () } ) . await ; ` ` `