[][src]Struct async_mongodb_session::MongodbSessionStore

pub struct MongodbSessionStore { /* fields omitted */ }

A MongoDB session store.

Implementations

impl MongodbSessionStore[src]

pub async fn new<'_, '_, '_>(
    uri: &'_ str,
    db: &'_ str,
    coll_name: &'_ str
) -> Result<Self>
[src]

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]

impl Debug for MongodbSessionStore[src]

impl SessionStore for MongodbSessionStore[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,