Skip to main content

InMemoryMagicCodeBackend

Struct InMemoryMagicCodeBackend 

Source
pub struct InMemoryMagicCodeBackend { /* private fields */ }
Expand description

In-memory backend for magic codes. The default — also used as the authoritative cache by MagicCodeStore.

Implementations§

Trait Implementations§

Source§

impl Default for InMemoryMagicCodeBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MagicCodeBackend for InMemoryMagicCodeBackend

Source§

fn put(&self, email: &str, code: &MagicCode)

Replace any existing code for email with code.
Source§

fn get(&self, email: &str) -> Option<MagicCode>

Look up the current code for email. Returns None if absent.
Source§

fn remove(&self, email: &str)

Remove the code for email (called on successful verify or expiry). Idempotent — missing key is not an error.
Source§

fn bump_attempts(&self, email: &str)

Persist an attempts++ on the existing record without touching other fields. Used by the verify-failed path to enforce MAX_ATTEMPTS across restarts.
Source§

fn load_all(&self) -> Vec<MagicCode>

Load all live records on construction. Lets MagicCodeStore::with_backend hydrate the in-memory cache from durable storage on startup.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V