pub struct ConfirmationCache {
inner: RwLock<HashMap<String, ConfirmationRecord>>,
}Expand description
Thread-safe in-memory cache of pending confirmation tokens.
Managed as Tauri state via ConfirmationCacheHandle.
§Lifecycle
mint(scope)— called bycross_account_confirm; returns a UUID token.consume(token, scope)— called bycopy_object_with_fallbackon the “above threshold + token present” path; returnstrueiff the token is valid, unexpired, unconsumed, and matches the given scope.
Expired and consumed entries are pruned lazily on each mint call so
the map stays small without a background task.
Fields§
§inner: RwLock<HashMap<String, ConfirmationRecord>>Implementations§
Source§impl ConfirmationCache
impl ConfirmationCache
Sourcepub fn mint(&self, scope: ConfirmScope) -> String
pub fn mint(&self, scope: ConfirmScope) -> String
Mint a new single-use token bound to scope.
Prunes expired/consumed entries before inserting the new one. Returns the UUID v4 token string.
Sourcepub fn consume(&self, token: &str, scope: &ConfirmScope) -> bool
pub fn consume(&self, token: &str, scope: &ConfirmScope) -> bool
Consume token if it matches scope and is still valid.
Returns true (and marks the record consumed) when:
- the token exists in the map,
- the record is not expired,
- the record has not been consumed already,
- and the scope fields match exactly.
Returns false in all other cases.
Trait Implementations§
Source§impl Default for ConfirmationCache
impl Default for ConfirmationCache
Source§fn default() -> ConfirmationCache
fn default() -> ConfirmationCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ConfirmationCache
impl RefUnwindSafe for ConfirmationCache
impl Send for ConfirmationCache
impl Sync for ConfirmationCache
impl Unpin for ConfirmationCache
impl UnsafeUnpin for ConfirmationCache
impl UnwindSafe for ConfirmationCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.