Struct portier::MemoryStore

source ·
pub struct MemoryStore<C> { /* private fields */ }
Expand description

A Store implementation that keeps everything in-memory.

This is the default Store implementation if a Client is used without explicitely configuring one.

Note that the cache in this store only grows. For clients that only talk to a trusted broker (the default), this is fine, because it can be assumed only a couple of URLs are fetched periodically.

This store will only function correctly if the application is a single process. When running multiple workers, the different processes will not be able to recognize eachothers’ sessions.

Restarting the application process will also cause a complete loss of all sessions. For low traffic sites, this may be fine, because sessions are short-lived.

Implementations§

source§

impl<C> MemoryStore<C>

source

pub fn with_http_client(client: C, timeout: Duration) -> Self

Create a store with a custom HTTP client configuration.

If defaults are fine, use the Default implementation instead.

Trait Implementations§

source§

impl Default for MemoryStore<Client<HttpsConnector<HttpConnector>>>

source§

fn default() -> Self

Create a store with a default configuration.

This create a Hyper client that uses native-tls for secure connections, and configures a timeout of 30-seconds for each request.

source§

impl<C> Store for MemoryStore<C>where C: Service<Request<Body>, Response = Response<Body>> + Clone + Send + Sync + 'static, C::Error: StdError + Send + Sync + 'static, C::Future: Send,

source§

fn fetch( &self, url: Url ) -> Pin<Box<dyn Future<Output = Result<Bytes, FetchError>> + Send>>

Requests a document using HTTP GET, and perform caching. Read more
source§

fn new_nonce( &self, email: String ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error + Send + Sync>>> + Send>>

Generate a random nonce and store the pair nonce/email. Read more
source§

fn consume_nonce( &self, nonce: String, email: String ) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error + Send + Sync>>> + Send>>

Check that a nonce/email pair exists and delete it if so. Read more

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for MemoryStore<C>where C: RefUnwindSafe,

§

impl<C> Send for MemoryStore<C>where C: Send,

§

impl<C> Sync for MemoryStore<C>where C: Sync,

§

impl<C> Unpin for MemoryStore<C>where C: Unpin,

§

impl<C> UnwindSafe for MemoryStore<C>where C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more