pub struct NonceStore { /* private fields */ }Expand description
Nonce store for replay protection
Implementations§
Source§impl NonceStore
impl NonceStore
Sourcepub fn with_config(max_nonces: usize, expiration_secs: u64) -> Self
pub fn with_config(max_nonces: usize, expiration_secs: u64) -> Self
Create a nonce store with custom settings
Sourcepub fn current_timestamp() -> u64
pub fn current_timestamp() -> u64
Get the current timestamp in seconds since UNIX epoch
Sourcepub fn is_expired(&self, timestamp: u64) -> bool
pub fn is_expired(&self, timestamp: u64) -> bool
Check if a timestamp is expired
Sourcepub fn check_nonce(
&mut self,
nonce: u64,
timestamp: u64,
) -> Result<(), SecurityError>
pub fn check_nonce( &mut self, nonce: u64, timestamp: u64, ) -> Result<(), SecurityError>
Check and record a nonce Returns Ok(()) if the nonce is valid and not seen before Returns Err(ReplayAttack) if the nonce was already used Returns Err(ExpiredTimestamp) if the timestamp is too old
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Remove expired nonces from the store
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NonceStore
impl RefUnwindSafe for NonceStore
impl Send for NonceStore
impl Sync for NonceStore
impl Unpin for NonceStore
impl UnsafeUnpin for NonceStore
impl UnwindSafe for NonceStore
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