Struct spa_rs::session::AddSession
source · [−]pub struct AddSession<T>(_);Expand description
Middleware that can access and modify all sessions data. Usually used for Login handler
Example
#[derive(PartialEq, Clone)]
struct User;
async fn login(Extension(session): Extension<Arc<SessionStore<User>>>) {
let new_user = User;
session.insert("session_id", new_user);
}
#[tokio::main]
async fn main() {
let session = Arc::new(SessionStore::<User>::new("my_session"));
let app = Router::new()
.route("/login", post(login))
.layer(FilterExLayer::new(AddSession::new(session.clone())));
}Implementations
sourceimpl<T> AddSession<T>
impl<T> AddSession<T>
pub fn new(store: Arc<SessionStore<T>>) -> Self
Trait Implementations
sourceimpl<T: Clone> Clone for AddSession<T>
impl<T: Clone> Clone for AddSession<T>
sourcefn clone(&self) -> AddSession<T>
fn clone(&self) -> AddSession<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<T: Debug> Debug for AddSession<T>
impl<T: Debug> Debug for AddSession<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for AddSession<T>
impl<T> Send for AddSession<T> where
T: Send + Sync,
impl<T> Sync for AddSession<T> where
T: Send + Sync,
impl<T> Unpin for AddSession<T>
impl<T> !UnwindSafe for AddSession<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more