Struct rocket_session::SessionFairing
source · Expand description
Fairing struct
Implementations§
source§impl<D> SessionFairing<D>where
D: 'static + Sync + Send + Default,
impl<D> SessionFairing<D>where
D: 'static + Sync + Send + Default,
sourcepub fn with_lifetime(self, time: Duration) -> Self
pub fn with_lifetime(self, time: Duration) -> Self
Set session lifetime (expiration time).
Call on the fairing before passing it to rocket.attach()
Examples found in repository?
More examples
examples/visit_counter/main.rs (line 27)
21 22 23 24 25 26 27 28 29 30 31 32 33
fn rocket() -> _ {
rocket::build()
.attach(
Session::fairing()
// 10 seconds of inactivity until session expires
// (wait 10s and refresh, the numbers will reset)
.with_lifetime(Duration::from_secs(10))
// custom cookie name and length
.with_cookie_name("my_cookie")
.with_cookie_len(20),
)
.mount("/", routes![index, about])
}
Set session cookie name and length
Call on the fairing before passing it to rocket.attach()
Examples found in repository?
examples/visit_counter/main.rs (line 29)
21 22 23 24 25 26 27 28 29 30 31 32 33
fn rocket() -> _ {
rocket::build()
.attach(
Session::fairing()
// 10 seconds of inactivity until session expires
// (wait 10s and refresh, the numbers will reset)
.with_lifetime(Duration::from_secs(10))
// custom cookie name and length
.with_cookie_name("my_cookie")
.with_cookie_len(20),
)
.mount("/", routes![index, about])
}
Set session cookie name and length
Call on the fairing before passing it to rocket.attach()
Examples found in repository?
examples/visit_counter/main.rs (line 30)
21 22 23 24 25 26 27 28 29 30 31 32 33
fn rocket() -> _ {
rocket::build()
.attach(
Session::fairing()
// 10 seconds of inactivity until session expires
// (wait 10s and refresh, the numbers will reset)
.with_lifetime(Duration::from_secs(10))
// custom cookie name and length
.with_cookie_name("my_cookie")
.with_cookie_len(20),
)
.mount("/", routes![index, about])
}
Set session cookie name and length
Call on the fairing before passing it to rocket.attach()
Trait Implementations§
source§impl<D> Default for SessionFairing<D>where
D: 'static + Sync + Send + Default + Default,
impl<D> Default for SessionFairing<D>where
D: 'static + Sync + Send + Default + Default,
source§fn default() -> SessionFairing<D>
fn default() -> SessionFairing<D>
Returns the “default value” for a type. Read more
source§impl<D> Fairing for SessionFairing<D>where
D: 'static + Sync + Send + Default,
impl<D> Fairing for SessionFairing<D>where
D: 'static + Sync + Send + Default,
source§fn on_ignite<'life0, 'async_trait>(
&'life0 self,
rocket: Rocket<Build>
) -> Pin<Box<dyn Future<Output = Result<Rocket<Build>, Rocket<Build>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_ignite<'life0, 'async_trait>(
&'life0 self,
rocket: Rocket<Build>
) -> Pin<Box<dyn Future<Output = Result<Rocket<Build>, Rocket<Build>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The ignite callback. Returns
Ok
if ignition should proceed and Err
if ignition and launch should be aborted. Read moresource§fn on_response<'r, 'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'r Request<'life1>,
response: &'life2 mut Response<'_>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'r: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_response<'r, 'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'r Request<'life1>,
response: &'life2 mut Response<'_>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'r: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The response callback. Read more
source§fn on_liftoff<'life0, 'life1, 'async_trait>(
&'life0 self,
_rocket: &'life1 Rocket<Orbit>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn on_liftoff<'life0, 'life1, 'async_trait>(
&'life0 self,
_rocket: &'life1 Rocket<Orbit>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
The liftoff callback. Read more
source§fn on_request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_req: &'life1 mut Request<'life2>,
_data: &'life3 mut Data<'life4>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn on_request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_req: &'life1 mut Request<'life2>,
_data: &'life3 mut Data<'life4>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
The request callback. Read more
Auto Trait Implementations§
impl<D> RefUnwindSafe for SessionFairing<D>where
D: RefUnwindSafe,
impl<D> Send for SessionFairing<D>
impl<D> Sync for SessionFairing<D>
impl<D> Unpin for SessionFairing<D>where
D: Unpin,
impl<D> UnwindSafe for SessionFairing<D>where
D: UnwindSafe,
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
§fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
Converts
self
into a collection.