pub struct FixedWindowCell { /* private fields */ }Expand description
Lock-free single-AtomicU64 fixed-window state cell packing (window_id, count).
Implementations§
Source§impl FixedWindowCell
Lock-free atomic fixed-window operations on FixedWindowCell.
impl FixedWindowCell
Lock-free atomic fixed-window operations on FixedWindowCell.
Sourcepub fn is_idle_at_ns(&self, config: &FixedWindowConfig, now_ns: u64) -> bool
pub fn is_idle_at_ns(&self, config: &FixedWindowConfig, now_ns: u64) -> bool
Sourcepub fn peek_at_ns(
&self,
config: &FixedWindowConfig,
now_ns: u64,
) -> RateLimitDecision
pub fn peek_at_ns( &self, config: &FixedWindowConfig, now_ns: u64, ) -> RateLimitDecision
Sourcepub fn check_n_at_ns(
&self,
config: &FixedWindowConfig,
now_ns: u64,
cost: u64,
) -> RateLimitDecision
pub fn check_n_at_ns( &self, config: &FixedWindowConfig, now_ns: u64, cost: u64, ) -> RateLimitDecision
Atomically checks and consumes cost units at monotonic timestamp now_ns.
§Arguments
&Self- The fixed-window cell.&FixedWindowConfig- Fixed-window configuration.u64- Current monotonic timestamp in nanoseconds.u64- Request cost in units.
§Returns
RateLimitDecision- Admission decision and nanosecond timings.
Trait Implementations§
Source§impl Debug for FixedWindowCell
impl Debug for FixedWindowCell
Auto Trait Implementations§
impl !Freeze for FixedWindowCell
impl Forget for FixedWindowCell
impl Move for FixedWindowCell
impl RefUnwindSafe for FixedWindowCell
impl Send for FixedWindowCell
impl Sync for FixedWindowCell
impl Unpin for FixedWindowCell
impl UnsafeUnpin for FixedWindowCellwhere
Align8<u64>: UnsafeUnpin,
impl UnwindSafe for FixedWindowCellwhere
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