pub struct NonceCache { /* private fields */ }Expand description
Remembers spent nonces. Cheap to share behind a &'static or an Arc.
Implementations§
Source§impl NonceCache
impl NonceCache
Sourcepub const fn new(capacity: usize, retention_seconds: i64) -> Self
pub const fn new(capacity: usize, retention_seconds: i64) -> Self
A cache holding at most capacity nonces, each for at least
retention_seconds.
Sourcepub fn admit(&self, nonce: &str, now: i64, valid_until: i64) -> bool
pub fn admit(&self, nonce: &str, now: i64, valid_until: i64) -> bool
Record nonce as spent at now (unix seconds). Returns true when it
was fresh and is now recorded, false when it was already spent.
valid_until is the last unix second at which the ticket carrying the
nonce could still verify; the entry is kept at least that long, so a
ticket can never outlive its own replay record.
Auto Trait Implementations§
impl !Freeze for NonceCache
impl RefUnwindSafe for NonceCache
impl Send for NonceCache
impl Sync for NonceCache
impl Unpin for NonceCache
impl UnsafeUnpin for NonceCache
impl UnwindSafe for NonceCache
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