pub struct BandwidthTracker {
pub window_ms: u64,
/* private fields */
}Expand description
Rolling-window bandwidth meter.
Call record_send / record_recv with byte counts and the current
millisecond timestamp. Query bytes_per_sec_up / bytes_per_sec_down
to get the rolling rate.
Fields§
§window_ms: u64Length of the rolling window in milliseconds.
Implementations§
Source§impl BandwidthTracker
impl BandwidthTracker
pub fn new(window_ms: u64) -> Self
Sourcepub fn default_window() -> Self
pub fn default_window() -> Self
Default 1-second rolling window.
Sourcepub fn record_send(&mut self, bytes: usize, now_ms: u64)
pub fn record_send(&mut self, bytes: usize, now_ms: u64)
Record bytes sent at time now_ms.
Sourcepub fn record_recv(&mut self, bytes: usize, now_ms: u64)
pub fn record_recv(&mut self, bytes: usize, now_ms: u64)
Record bytes received at time now_ms.
Sourcepub fn bytes_per_sec_up(&self, now_ms: u64) -> f64
pub fn bytes_per_sec_up(&self, now_ms: u64) -> f64
Bytes per second upload over the rolling window.
Sourcepub fn bytes_per_sec_down(&self, now_ms: u64) -> f64
pub fn bytes_per_sec_down(&self, now_ms: u64) -> f64
Bytes per second download over the rolling window.
pub fn total_bytes_sent(&self) -> u64
pub fn total_bytes_recv(&self) -> u64
Auto Trait Implementations§
impl Freeze for BandwidthTracker
impl RefUnwindSafe for BandwidthTracker
impl Send for BandwidthTracker
impl Sync for BandwidthTracker
impl Unpin for BandwidthTracker
impl UnsafeUnpin for BandwidthTracker
impl UnwindSafe for BandwidthTracker
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