pub enum SessionDriver {
Memory,
Database,
Cache,
Cookie,
}Expand description
Which SessionStore to build.
use rainier_session::SessionDriver;
use rainier_support::Setting;
assert_eq!(SessionDriver::parse("cookie").unwrap(), SessionDriver::Cookie);
assert!(SessionDriver::parse("redis").is_err(), "sessions go in the cache, not a driver of their own");Note what is not here: redis. Sessions in Redis are the cache
driver pointed at Redis, which is one store to configure rather than
two, and one connection pool rather than two.
Variants§
Memory
This process only. Sessions vanish on restart and are not shared between instances, so a second instance logs everyone out.
The default because it needs nothing, and wrong for anything with more than one process.
Database
A table in the application’s own database.
Shared, durable, and revocable. Needs the migration —
DatabaseSessionStore::migrations() — and something to call
prune() periodically.
Cache
Whatever the cache is pointed at: Redis, a Redis Cluster, or Memcached, all behind one port.
The cache expires them itself, so nothing has to sweep.
Cookie
The whole session, encrypted, in the cookie.
No server state at all — and therefore no way to revoke a session short of rotating the key, and a hard size limit. Read the docs before choosing it.
Implementations§
Source§impl SessionDriver
impl SessionDriver
Source§impl SessionDriver
impl SessionDriver
Sourcepub fn is_durable(&self) -> bool
pub fn is_durable(&self) -> bool
Whether sessions survive a restart of the process that made them.
Sourcepub fn is_revocable(&self) -> bool
pub fn is_revocable(&self) -> bool
Whether the server can end a session it has already issued.
false for Cookie, and that is the property that
decides whether it is usable: a logout, a password change and a stolen
cookie all need this.
Whether every instance of the application sees the same sessions.
Trait Implementations§
Source§impl AsRef<str> for SessionDriver
impl AsRef<str> for SessionDriver
Source§impl Clone for SessionDriver
impl Clone for SessionDriver
Source§fn clone(&self) -> SessionDriver
fn clone(&self) -> SessionDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SessionDriver
Source§impl Debug for SessionDriver
impl Debug for SessionDriver
Source§impl Default for SessionDriver
impl Default for SessionDriver
Source§fn default() -> SessionDriver
fn default() -> SessionDriver
Source§impl<'de> Deserialize<'de> for SessionDriver
impl<'de> Deserialize<'de> for SessionDriver
Source§fn deserialize<D>(
deserializer: D,
) -> Result<SessionDriver, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SessionDriver, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for SessionDriver
impl Display for SessionDriver
impl Eq for SessionDriver
Source§impl FromStr for SessionDriver
impl FromStr for SessionDriver
Source§impl Hash for SessionDriver
impl Hash for SessionDriver
Source§impl PartialEq for SessionDriver
impl PartialEq for SessionDriver
Source§impl Serialize for SessionDriver
impl Serialize for SessionDriver
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl Setting for SessionDriver
impl Setting for SessionDriver
Source§const SETTING: &'static str = "session driver"
const SETTING: &'static str = "session driver"
"cache driver". Read moreSource§const ALL: &'static [SessionDriver]
const ALL: &'static [SessionDriver]
impl StructuralPartialEq for SessionDriver
Auto Trait Implementations§
impl Freeze for SessionDriver
impl RefUnwindSafe for SessionDriver
impl Send for SessionDriver
impl Sync for SessionDriver
impl Unpin for SessionDriver
impl UnsafeUnpin for SessionDriver
impl UnwindSafe for SessionDriver
Blanket Implementations§
impl<T> Actor for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more