pub struct ReplayProtection { /* private fields */ }Expand description
Replay protection using nonce tracking
Tracks seen nonces within a time window to prevent replay attacks. Old nonces are automatically cleaned up to prevent memory exhaustion.
Implementations§
Source§impl ReplayProtection
impl ReplayProtection
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new replay protection with default settings
Default window: 120 seconds (2x the timestamp validation window) Max entries: 100,000 nonces
Sourcepub fn with_config(window: Duration, max_entries: usize) -> Self
pub fn with_config(window: Duration, max_entries: usize) -> Self
Create with custom window and max entries
Sourcepub fn check_and_record(&self, nonce: u32) -> Result<()>
pub fn check_and_record(&self, nonce: u32) -> Result<()>
Check if nonce has been seen before and record it
Returns:
- Ok(()) if nonce is new
- Err if nonce is duplicate (replay attack detected)
Sourcepub fn stats(&self) -> ReplayProtectionStats
pub fn stats(&self) -> ReplayProtectionStats
Get current cache statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ReplayProtection
impl !RefUnwindSafe for ReplayProtection
impl Send for ReplayProtection
impl Sync for ReplayProtection
impl Unpin for ReplayProtection
impl UnsafeUnpin for ReplayProtection
impl UnwindSafe for ReplayProtection
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