pub struct AdminRateLimiter { /* private fields */ }Expand description
Per-client sliding-window rate limiter for admin API endpoints.
Tracks request timestamps per source key (IP address or API key), preventing a single attacker from exhausting the rate limit budget for all legitimate operators.
Implementations§
Source§impl AdminRateLimiter
impl AdminRateLimiter
Sourcepub fn new(max_requests: u64, window_duration: Duration) -> Self
pub fn new(max_requests: u64, window_duration: Duration) -> Self
Create a new rate limiter with the given capacity and window duration.
Sourcepub fn check_rate_limit(&self, client_key: &str) -> bool
pub fn check_rate_limit(&self, client_key: &str) -> bool
Check whether a request from the given client key should be allowed.
Returns true if the request is within the rate limit, false if it
should be rejected.
Sourcepub fn check_rate_limit_global(&self) -> bool
pub fn check_rate_limit_global(&self) -> bool
Backward-compatible global check (uses “global” as the key).
Auto Trait Implementations§
impl !Freeze for AdminRateLimiter
impl RefUnwindSafe for AdminRateLimiter
impl Send for AdminRateLimiter
impl Sync for AdminRateLimiter
impl Unpin for AdminRateLimiter
impl UnsafeUnpin for AdminRateLimiter
impl UnwindSafe for AdminRateLimiter
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