pub struct NetworkHistory { /* private fields */ }Expand description
Circular buffer storing network snapshots for bandwidth and sparkline calculations.
Bandwidth is computed as bytes/s using timestamps from consecutive snapshots. Sparkline values are byte deltas between consecutive samples (not normalized to time — suitable for fixed-interval display).
Implementations§
Source§impl NetworkHistory
impl NetworkHistory
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new history buffer with the given capacity. Capacity is clamped to a minimum of 2 (needed for delta computation).
Sourcepub fn push(&mut self, snapshot: NetworkSnapshot)
pub fn push(&mut self, snapshot: NetworkSnapshot)
Push a new snapshot, evicting the oldest if at capacity.
Sourcepub fn bandwidth_rx(&self, iface: &str) -> f64
pub fn bandwidth_rx(&self, iface: &str) -> f64
Compute RX bandwidth in bytes/s for a given interface over the last interval. Returns 0.0 if fewer than 2 samples or interface not found.
Sourcepub fn bandwidth_tx(&self, iface: &str) -> f64
pub fn bandwidth_tx(&self, iface: &str) -> f64
Compute TX bandwidth in bytes/s for a given interface over the last interval. Returns 0.0 if fewer than 2 samples or interface not found.
Trait Implementations§
Source§impl Clone for NetworkHistory
impl Clone for NetworkHistory
Source§fn clone(&self) -> NetworkHistory
fn clone(&self) -> NetworkHistory
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 NetworkHistory
impl RefUnwindSafe for NetworkHistory
impl Send for NetworkHistory
impl Sync for NetworkHistory
impl Unpin for NetworkHistory
impl UnsafeUnpin for NetworkHistory
impl UnwindSafe for NetworkHistory
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