pub struct NormalizedStringRateLimiter { /* private fields */ }Expand description
A keyed string rate limiter with product-neutral key normalization.
The limiter trims surrounding whitespace and lowercases keys before checking the quota. This suits usernames, email addresses, provider IDs, and similar business-unique identifiers where accidental case differences should not bypass a rate limit.
Implementations§
Source§impl NormalizedStringRateLimiter
impl NormalizedStringRateLimiter
Sourcepub fn new(
enabled: bool,
seconds_per_request: NonZeroU64,
burst_size: NonZeroU32,
) -> Self
pub fn new( enabled: bool, seconds_per_request: NonZeroU64, burst_size: NonZeroU32, ) -> Self
Builds a limiter from a non-zero quota and enabled flag.
Sourcepub fn check(&self, raw_key: &str) -> Option<RateLimitRejection>
pub fn check(&self, raw_key: &str) -> Option<RateLimitRejection>
Checks a raw key after trimming whitespace and lowercasing it.
Trait Implementations§
Source§impl Clone for NormalizedStringRateLimiter
impl Clone for NormalizedStringRateLimiter
Source§fn clone(&self) -> NormalizedStringRateLimiter
fn clone(&self) -> NormalizedStringRateLimiter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NormalizedStringRateLimiter
impl !RefUnwindSafe for NormalizedStringRateLimiter
impl Send for NormalizedStringRateLimiter
impl Sync for NormalizedStringRateLimiter
impl Unpin for NormalizedStringRateLimiter
impl UnsafeUnpin for NormalizedStringRateLimiter
impl !UnwindSafe for NormalizedStringRateLimiter
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