[−][src]Struct async_mongodb_session::MongodbSessionStore
A MongoDB session store.
Implementations
impl MongodbSessionStore
[src]
pub async fn new<'_, '_, '_>(
uri: &'_ str,
db: &'_ str,
coll_name: &'_ str
) -> Result<Self>
[src]
uri: &'_ str,
db: &'_ str,
coll_name: &'_ str
) -> Result<Self>
Create a new instance of MongodbSessionStore
after stablish the connection to monngodb.
let store = MongodbSessionStore::new("mongodb://127.0.0.1:27017", "db_name", "collection") .await?;
pub fn from_client(client: Client, db: &str, coll_name: &str) -> Self
[src]
Create a new instance of MongodbSessionStore
from an open client.
use mongodb::{options::ClientOptions, Client}; let client_options = match ClientOptions::parse("mongodb://127.0.0.1:27017").await { Ok(c) => c, Err(e) => panic!("Client Options Failed: {}", e), }; let client = match Client::with_options(client_options) { Ok(c) => c, Err(e) => panic!("Client Creation Failed: {}", e), }; let store = MongodbSessionStore::from_client(client, "db_name", "collection");
pub async fn initialize<'_>(&'_ self) -> Result
[src]
Initialize the default expiration mechanism, based on the document expiration
that mongodb provides https://docs.mongodb.com/manual/tutorial/expire-data/#expire-documents-at-a-specific-clock-time.
The default ttl applyed to sessions without expiry is 20 minutes.
If the expireAt
date field contains a date in the past, mongodb considers the document expired and will be deleted.
Note: mongodb runs the expiration logic every 60 seconds.
let store = MongodbSessionStore::new("mongodb://127.0.0.1:27017", "db_name", "collection") .await?; store.initialize().await?;
pub async fn index_on_expiry_at<'_>(&'_ self) -> Result
[src]
Create a new index for the expireAt
property, allowing to expire sessions at a specific clock time.
If the expireAt
date field contains a date in the past, mongodb considers the document expired and will be deleted.
https://docs.mongodb.com/manual/tutorial/expire-data/#expire-documents-at-a-specific-clock-time
let store = MongodbSessionStore::new("mongodb://127.0.0.1:27017", "db_name", "collection") .await?; store.index_on_expiry_at().await?;
Trait Implementations
impl Clone for MongodbSessionStore
[src]
pub fn clone(&self) -> MongodbSessionStore
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MongodbSessionStore
[src]
impl SessionStore for MongodbSessionStore
[src]
pub fn store_session<'life0, 'async_trait>(
&'life0 self,
session: Session
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
session: Session
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
pub fn load_session<'life0, 'async_trait>(
&'life0 self,
cookie_value: String
) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
cookie_value: String
) -> Pin<Box<dyn Future<Output = Result<Option<Session>>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
pub fn destroy_session<'life0, 'async_trait>(
&'life0 self,
session: Session
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
session: Session
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
pub fn clear_store<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl !RefUnwindSafe for MongodbSessionStore
[src]
impl Send for MongodbSessionStore
[src]
impl Sync for MongodbSessionStore
[src]
impl Unpin for MongodbSessionStore
[src]
impl !UnwindSafe for MongodbSessionStore
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,