pub struct Session(_);
Expand description
The high-level interface you use to modify session data.
Session object could be obtained with
RequestSession::session
method. RequestSession
trait is implemented for HttpRequest
.
use actix_web::middleware::session::RequestSession;
use actix_web::*;
fn index(mut req: HttpRequest) -> Result<&'static str> {
// access session data
if let Some(count) = req.session().get::<i32>("counter")? {
req.session().set("counter", count + 1)?;
} else {
req.session().set("counter", 1)?;
}
Ok("Welcome!")
}
Implementations§
Trait Implementations§
source§impl<S> FromRequest<S> for Session
impl<S> FromRequest<S> for Session
Extractor implementation for Session type.
use actix_web::middleware::session::Session;
fn index(session: Session) -> Result<&'static str> {
// access session data
if let Some(count) = session.get::<i32>("counter")? {
session.set("counter", count + 1)?;
} else {
session.set("counter", 1)?;
}
Ok("Welcome!")
}
source§fn from_request(
req: &HttpRequest<S>,
_: &<Session as FromRequest<S>>::Config
) -> <Session as FromRequest<S>>::Result
fn from_request(
req: &HttpRequest<S>,
_: &<Session as FromRequest<S>>::Config
) -> <Session as FromRequest<S>>::Result
Convert request to a Self
Auto Trait Implementations§
impl !RefUnwindSafe for Session
impl !Send for Session
impl !Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
Convert
&self
to an expression for Diesel’s query builder. Read more