pub struct RateLimitTracker { /* private fields */ }Implementations§
Source§impl RateLimitTracker
impl RateLimitTracker
Sourcepub fn record_request(&mut self)
pub fn record_request(&mut self)
记录一个请求
Sourcepub fn is_rate_limited(&mut self, rate_limit: f32) -> bool
pub fn is_rate_limited(&mut self, rate_limit: f32) -> bool
检查是否达到限速(毫秒级)
Sourcepub fn get_current_rate(&self) -> f32
pub fn get_current_rate(&self) -> f32
获取当前请求频率(毫秒级)
Sourcepub fn remaining_in_window(&self) -> Duration
pub fn remaining_in_window(&self) -> Duration
剩余窗口时长(用于等待)
Sourcepub fn current_window_count(&self) -> u32
pub fn current_window_count(&self) -> u32
当前窗口内已计数的请求数(若窗口已过期则返回0)
Trait Implementations§
Source§impl Clone for RateLimitTracker
impl Clone for RateLimitTracker
Source§fn clone(&self) -> RateLimitTracker
fn clone(&self) -> RateLimitTracker
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RateLimitTracker
impl RefUnwindSafe for RateLimitTracker
impl Send for RateLimitTracker
impl Sync for RateLimitTracker
impl Unpin for RateLimitTracker
impl UnsafeUnpin for RateLimitTracker
impl UnwindSafe for RateLimitTracker
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