pub struct FixedWindowState {
pub key: String,
pub hit_count: usize,
pub interval: i64,
pub max_size: usize,
pub timer: i64,
}Fields§
§key: String§hit_count: usize§interval: i64§max_size: usize§timer: i64Implementations§
Source§impl FixedWindowState
impl FixedWindowState
pub fn new(key: String, interval: &Duration, max_size: usize) -> Self
pub fn add(&mut self, hits: Option<usize>, now: Option<&DateTime<Local>>)
pub fn get_available_tokens(&self, now: &DateTime<Local>) -> Option<usize>
pub fn calculate_time_for_tokens( &self, tokens: usize, now: &DateTime<Local>, ) -> i64
Trait Implementations§
Source§impl Clone for FixedWindowState
impl Clone for FixedWindowState
Source§fn clone(&self) -> FixedWindowState
fn clone(&self) -> FixedWindowState
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 FixedWindowState
impl Debug for FixedWindowState
Source§impl State<FixedWindowState> for FixedWindowState
impl State<FixedWindowState> for FixedWindowState
Auto Trait Implementations§
impl Freeze for FixedWindowState
impl RefUnwindSafe for FixedWindowState
impl Send for FixedWindowState
impl Sync for FixedWindowState
impl Unpin for FixedWindowState
impl UnwindSafe for FixedWindowState
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