pub struct SlidingWindowState {
pub key: String,
pub interval: i64,
pub window_end_at: i64,
/* private fields */
}Fields§
§key: String§interval: i64§window_end_at: i64Implementations§
Source§impl SlidingWindowState
impl SlidingWindowState
pub fn new(key: String, interval: &Duration) -> Self
pub fn create_from_previous_window(window: &Self, interval: &Duration) -> Self
pub fn get_expiration_time(&self) -> i64
pub fn is_expired(&self) -> bool
pub fn add(&mut self, hits: Option<usize>)
Sourcepub fn get_hit_count(&self) -> usize
pub fn get_hit_count(&self) -> usize
Calculates the sliding window number of request.
pub fn calculate_time_for_tokens(&self, max_size: usize, tokens: usize) -> i64
Trait Implementations§
Source§impl Clone for SlidingWindowState
impl Clone for SlidingWindowState
Source§fn clone(&self) -> SlidingWindowState
fn clone(&self) -> SlidingWindowState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SlidingWindowState
impl Debug for SlidingWindowState
Source§impl State<SlidingWindowState> for SlidingWindowState
impl State<SlidingWindowState> for SlidingWindowState
Auto Trait Implementations§
impl Freeze for SlidingWindowState
impl RefUnwindSafe for SlidingWindowState
impl Send for SlidingWindowState
impl Sync for SlidingWindowState
impl Unpin for SlidingWindowState
impl UnwindSafe for SlidingWindowState
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