pub struct RateLimitState { /* private fields */ }Expand description
Mutable state for per-peer rate-limit tracking.
Cheap clone (Arc internally).
Implementations§
Source§impl RateLimitState
impl RateLimitState
Sourcepub fn new(config: RateLimitConfig) -> Self
pub fn new(config: RateLimitConfig) -> Self
Construct fresh state with the given config.
Sourcepub fn check(&self, peer: &PeerKey, bucket: RateBucket) -> RateLimitOutcome
pub fn check(&self, peer: &PeerKey, bucket: RateBucket) -> RateLimitOutcome
Attempt to debit one token from the (peer, bucket) bucket.
Trait Implementations§
Source§impl Clone for RateLimitState
impl Clone for RateLimitState
Source§fn clone(&self) -> RateLimitState
fn clone(&self) -> RateLimitState
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 moreAuto Trait Implementations§
impl Freeze for RateLimitState
impl !RefUnwindSafe for RateLimitState
impl Send for RateLimitState
impl Sync for RateLimitState
impl Unpin for RateLimitState
impl UnsafeUnpin for RateLimitState
impl !UnwindSafe for RateLimitState
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