pub struct RateLimiterConfig {
pub capacity: u32,
pub refill_period: Duration,
pub refill_amount: u32,
pub cost_per_request: u32,
}Expand description
Rate limiter configuration
Fields§
§capacity: u32Maximum number of tokens (requests) in the bucket
refill_period: DurationTime window for refilling tokens
refill_amount: u32Number of tokens to refill per period (defaults to capacity)
cost_per_request: u32Cost per request in tokens (defaults to 1)
Implementations§
Source§impl RateLimiterConfig
impl RateLimiterConfig
Sourcepub fn new(capacity: u32, refill_period: Duration) -> Self
pub fn new(capacity: u32, refill_period: Duration) -> Self
Create a new rate limiter configuration
§Arguments
capacity- Maximum number of requests allowed in the time windowrefill_period- Time window for the rate limit
§Example
use ccxt_core::rate_limiter::RateLimiterConfig;
use std::time::Duration;
// 100 requests per minute
let config = RateLimiterConfig::new(100, Duration::from_secs(60));Sourcepub fn with_refill_amount(self, amount: u32) -> Self
pub fn with_refill_amount(self, amount: u32) -> Self
Set custom refill amount (different from capacity)
Sourcepub fn with_cost_per_request(self, cost: u32) -> Self
pub fn with_cost_per_request(self, cost: u32) -> Self
Set custom cost per request
Trait Implementations§
Source§impl Clone for RateLimiterConfig
impl Clone for RateLimiterConfig
Source§fn clone(&self) -> RateLimiterConfig
fn clone(&self) -> RateLimiterConfig
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 RateLimiterConfig
impl Debug for RateLimiterConfig
Auto Trait Implementations§
impl Freeze for RateLimiterConfig
impl RefUnwindSafe for RateLimiterConfig
impl Send for RateLimiterConfig
impl Sync for RateLimiterConfig
impl Unpin for RateLimiterConfig
impl UnwindSafe for RateLimiterConfig
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