pub struct DpopNonceStore { /* private fields */ }Expand description
In-memory LRU nonce replay store.
Keys are (nonce, capability_id) pairs. Values are the Instant when
the nonce was first seen. A nonce is rejected if it is still within the
TTL window when seen a second time.
This is intentionally synchronous (no async) and uses std::sync::Mutex
so it integrates cleanly into the Guard pipeline.
Implementations§
Source§impl DpopNonceStore
impl DpopNonceStore
Sourcepub fn new(capacity: usize, ttl: Duration) -> Self
pub fn new(capacity: usize, ttl: Duration) -> Self
Create a new nonce store.
capacity is the maximum number of (nonce, capability_id) pairs to
remember. ttl is how long a nonce is considered “live” after first
use. After the TTL elapses, the same nonce can be used again.
Sourcepub fn check_and_insert(
&self,
nonce: &str,
capability_id: &str,
) -> Result<bool, KernelError>
pub fn check_and_insert( &self, nonce: &str, capability_id: &str, ) -> Result<bool, KernelError>
Check a nonce and insert it if not already live.
Returns Ok(true) if the nonce is fresh (accepted).
Returns Ok(false) if the nonce was already used within the TTL window
(rejected – replay detected).
Returns Err if the internal mutex is poisoned (fail-closed: deny).
Auto Trait Implementations§
impl !Freeze for DpopNonceStore
impl RefUnwindSafe for DpopNonceStore
impl Send for DpopNonceStore
impl Sync for DpopNonceStore
impl Unpin for DpopNonceStore
impl UnsafeUnpin for DpopNonceStore
impl UnwindSafe for DpopNonceStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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