pub struct HandoffTokenStore { /* private fields */ }Expand description
Bounded one-time token store for future handoff verification.
Implementations§
Source§impl HandoffTokenStore
impl HandoffTokenStore
Sourcepub fn with_config(config: HandoffTokenStoreConfig) -> Self
pub fn with_config(config: HandoffTokenStoreConfig) -> Self
Create an empty store with explicit bounds.
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Return the number of currently pending, non-pruned tokens.
Sourcepub fn issue(&mut self, now: Instant) -> Result<HandoffToken, HandoffTokenError>
pub fn issue(&mut self, now: Instant) -> Result<HandoffToken, HandoffTokenError>
Issue one pending token from operating-system randomness.
Sourcepub fn issue_with_random128<F>(
&mut self,
now: Instant,
next_random128: F,
) -> Result<HandoffToken, HandoffTokenError>
pub fn issue_with_random128<F>( &mut self, now: Instant, next_random128: F, ) -> Result<HandoffToken, HandoffTokenError>
Issue one pending token from a deterministic random source.
Tests use this to force collisions and capacity pressure without weakening the production randomness path.
Sourcepub fn consume_matching(
&mut self,
expected: &HandoffToken,
presented: &HandoffToken,
now: Instant,
) -> Result<(), HandoffTokenError>
pub fn consume_matching( &mut self, expected: &HandoffToken, presented: &HandoffToken, now: Instant, ) -> Result<(), HandoffTokenError>
Consume expected exactly once if the backend presented the same token.
A mismatch never consumes either token. Expired tokens are removed before returning an expiry error so the pending set remains bounded.
Sourcepub fn revoke(&mut self, token: &HandoffToken) -> bool
pub fn revoke(&mut self, token: &HandoffToken) -> bool
Revoke one pending token without consuming it.
Returns true when the token was pending. The broker uses this when a handoff is abandoned (backend ACK deadline expired) so a late backend presentation of the token is rejected as not pending.
Sourcepub fn prune_expired(&mut self, now: Instant) -> usize
pub fn prune_expired(&mut self, now: Instant) -> usize
Drop every expired token and return how many entries were removed.
Trait Implementations§
Source§impl Debug for HandoffTokenStore
impl Debug for HandoffTokenStore
Auto Trait Implementations§
impl Freeze for HandoffTokenStore
impl RefUnwindSafe for HandoffTokenStore
impl Send for HandoffTokenStore
impl Sync for HandoffTokenStore
impl Unpin for HandoffTokenStore
impl UnsafeUnpin for HandoffTokenStore
impl UnwindSafe for HandoffTokenStore
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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 more