Updates the parameters of the token buckets associated with this RateLimiter. TODO: Please note that, right now, the buckets become full after being updated.
(&mut self, bytes: BucketUpdate, ops: BucketUpdate)
| 485 | /// Updates the parameters of the token buckets associated with this RateLimiter. |
| 486 | // TODO: Please note that, right now, the buckets become full after being updated. |
| 487 | pub fn update_buckets(&mut self, bytes: BucketUpdate, ops: BucketUpdate) { |
| 488 | let guard = self.inner.get_mut().unwrap(); |
| 489 | match bytes { |
| 490 | BucketUpdate::Disabled => guard.bandwidth = None, |
| 491 | BucketUpdate::Update(tb) => guard.bandwidth = Some(tb), |
| 492 | BucketUpdate::None => (), |
| 493 | } |
| 494 | match ops { |
| 495 | BucketUpdate::Disabled => guard.ops = None, |
| 496 | BucketUpdate::Update(tb) => guard.ops = Some(tb), |
| 497 | BucketUpdate::None => (), |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | impl AsRawFd for RateLimiter { |