Struct gotham::middleware::session::MemoryBackend
source · [−]pub struct MemoryBackend { /* private fields */ }
Expand description
Defines the in-process memory based session storage.
This is the default implementation which is used by NewSessionMiddleware::default()
Implementations
sourceimpl MemoryBackend
impl MemoryBackend
sourcepub fn new(ttl: Duration) -> MemoryBackend
pub fn new(ttl: Duration) -> MemoryBackend
Creates a new MemoryBackend
where sessions expire and are removed after the ttl
has
elapsed.
Alternately, MemoryBackend::default()
creates a MemoryBackend
with a ttl
of one hour.
Examples
NewSessionMiddleware::new(MemoryBackend::new(Duration::from_secs(3600)))
Trait Implementations
sourceimpl Backend for MemoryBackend
impl Backend for MemoryBackend
sourcefn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8]
) -> Result<(), SessionError>
fn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8]
) -> Result<(), SessionError>
Persists a session, either creating a new session or updating an existing session.
sourcefn read_session(
&self,
identifier: SessionIdentifier
) -> Box<dyn Future<Item = Option<Vec<u8>>, Error = SessionError> + Send>
fn read_session(
&self,
identifier: SessionIdentifier
) -> Box<dyn Future<Item = Option<Vec<u8>>, Error = SessionError> + Send>
Retrieves a session from the underlying storage. Read more
sourcefn drop_session(
&self,
identifier: SessionIdentifier
) -> Result<(), SessionError>
fn drop_session(
&self,
identifier: SessionIdentifier
) -> Result<(), SessionError>
Drops a session from the underlying storage.
sourceimpl Clone for MemoryBackend
impl Clone for MemoryBackend
sourcefn clone(&self) -> MemoryBackend
fn clone(&self) -> MemoryBackend
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 Default for MemoryBackend
impl Default for MemoryBackend
sourcefn default() -> MemoryBackend
fn default() -> MemoryBackend
Returns the “default value” for a type. Read more
sourceimpl NewBackend for MemoryBackend
impl NewBackend for MemoryBackend
type Instance = MemoryBackend
type Instance = MemoryBackend
The type of Backend
created by the NewBackend
.
sourcefn new_backend(&self) -> Result<Self::Instance>
fn new_backend(&self) -> Result<Self::Instance>
Create and return a new Backend
value.
Auto Trait Implementations
impl RefUnwindSafe for MemoryBackend
impl Send for MemoryBackend
impl Sync for MemoryBackend
impl Unpin for MemoryBackend
impl UnwindSafe for MemoryBackend
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more