pub struct FixedWindowLimiter { /* private fields */ }Expand description
Lock-free atomic fixed-window rate limiter with an embedded monotonic clock.
Implementations§
Source§impl FixedWindowLimiter
Core lock-free operations for FixedWindowLimiter.
impl FixedWindowLimiter
Core lock-free operations for FixedWindowLimiter.
Sourcepub fn new(config: FixedWindowConfig) -> Self
pub fn new(config: FixedWindowConfig) -> Self
Creates a new FixedWindowLimiter from a validated FixedWindowConfig.
§Arguments
FixedWindowConfig- Validated fixed-window configuration.
Sourcepub fn with_clock(config: FixedWindowConfig, clock: MonotonicClock) -> Self
pub fn with_clock(config: FixedWindowConfig, clock: MonotonicClock) -> Self
Creates a new FixedWindowLimiter anchored at a caller-supplied MonotonicClock.
§Arguments
FixedWindowConfig- Validated fixed-window configuration.MonotonicClock- Monotonic clock origin.
Sourcepub fn get_config(&self) -> &FixedWindowConfig
pub fn get_config(&self) -> &FixedWindowConfig
Sourcepub fn get_clock(&self) -> &MonotonicClock
pub fn get_clock(&self) -> &MonotonicClock
Sourcepub fn check(&self) -> RateLimitDecision
pub fn check(&self) -> RateLimitDecision
Sourcepub fn check_n(&self, cost: u64) -> RateLimitDecision
pub fn check_n(&self, cost: u64) -> RateLimitDecision
Sourcepub fn check_at_ns(&self, now_ns: u64) -> RateLimitDecision
pub fn check_at_ns(&self, now_ns: u64) -> RateLimitDecision
Sourcepub fn check_n_at_ns(&self, now_ns: u64, cost: u64) -> RateLimitDecision
pub fn check_n_at_ns(&self, now_ns: u64, cost: u64) -> RateLimitDecision
Sourcepub fn peek(&self) -> RateLimitDecision
pub fn peek(&self) -> RateLimitDecision
Sourcepub fn peek_at_ns(&self, now_ns: u64) -> RateLimitDecision
pub fn peek_at_ns(&self, now_ns: u64) -> RateLimitDecision
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FixedWindowLimiter
impl Forget for FixedWindowLimiter
impl Move for FixedWindowLimiter
impl RefUnwindSafe for FixedWindowLimiter
impl Send for FixedWindowLimiter
impl Sync for FixedWindowLimiter
impl Unpin for FixedWindowLimiter
impl UnsafeUnpin for FixedWindowLimiterwhere
Align8<u64>: UnsafeUnpin,
impl UnwindSafe for FixedWindowLimiterwhere
Align8<u64>: UnwindSafe,
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