pub struct ThrottleConfig {
pub global_limit: u64,
pub per_ip_limit: u64,
pub bucket_capacity: u64,
pub refill_interval: Duration,
pub enabled: bool,
}Expand description
Bandwidth throttle configuration
Fields§
§global_limit: u64Global bandwidth limit in bytes per second (0 = unlimited)
per_ip_limit: u64Per-IP bandwidth limit in bytes per second (0 = unlimited)
bucket_capacity: u64Bucket capacity (burst size) in bytes
refill_interval: DurationRefill interval
enabled: boolEnabled flag
Implementations§
Source§impl ThrottleConfig
impl ThrottleConfig
Sourcepub fn with_global_limit(self, limit: u64) -> Self
pub fn with_global_limit(self, limit: u64) -> Self
Set global bandwidth limit (bytes/sec)
Sourcepub fn with_per_ip_limit(self, limit: u64) -> Self
pub fn with_per_ip_limit(self, limit: u64) -> Self
Set per-IP bandwidth limit (bytes/sec)
Sourcepub fn with_bucket_capacity(self, capacity: u64) -> Self
pub fn with_bucket_capacity(self, capacity: u64) -> Self
Set bucket capacity
Sourcepub fn with_refill_interval(self, interval: Duration) -> Self
pub fn with_refill_interval(self, interval: Duration) -> Self
Set refill interval
Sourcepub fn has_global_limit(&self) -> bool
pub fn has_global_limit(&self) -> bool
Check if global limit is set
Sourcepub fn has_per_ip_limit(&self) -> bool
pub fn has_per_ip_limit(&self) -> bool
Check if per-IP limit is set
Sourcepub fn tokens_per_interval(&self, limit: u64) -> u64
pub fn tokens_per_interval(&self, limit: u64) -> u64
Calculate tokens to add per interval
Sourcepub fn format_limit(bytes_per_sec: u64) -> String
pub fn format_limit(bytes_per_sec: u64) -> String
Create a human-readable limit string
Trait Implementations§
Source§impl Clone for ThrottleConfig
impl Clone for ThrottleConfig
Source§fn clone(&self) -> ThrottleConfig
fn clone(&self) -> ThrottleConfig
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 ThrottleConfig
impl Debug for ThrottleConfig
Auto Trait Implementations§
impl Freeze for ThrottleConfig
impl RefUnwindSafe for ThrottleConfig
impl Send for ThrottleConfig
impl Sync for ThrottleConfig
impl Unpin for ThrottleConfig
impl UnsafeUnpin for ThrottleConfig
impl UnwindSafe for ThrottleConfig
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