pub struct NetCounters {
pub rx_bytes: u64,
pub tx_bytes: u64,
}Expand description
Host-wide network byte counters, cumulative since boot.
Loopback is excluded by both backends: lo traffic never reaches a wire, and
counting it would both inflate the figure and double every byte (once as
received, once as transmitted). A container or a busy local database would
otherwise report hundreds of MB/s of “network” while the NIC is idle.
Fields§
§rx_bytes: u64§tx_bytes: u64Implementations§
Source§impl NetCounters
impl NetCounters
Sourcepub fn delta(&self, prev: &NetCounters) -> NetCounters
pub fn delta(&self, prev: &NetCounters) -> NetCounters
Counter delta against an earlier sample, saturating on reset.
A counter can go backwards: an interface is destroyed and recreated, or
the kernel wraps the counter on 32-bit if_data. Reporting a negative
rate (or a 4 GiB spike) for one tick is worse than reporting zero, so a
decreasing counter contributes nothing.
Sourcepub fn per_sec(&self, prev: &NetCounters, secs: f64) -> Rate
pub fn per_sec(&self, prev: &NetCounters, secs: f64) -> Rate
Bytes per second between two samples secs apart.
Trait Implementations§
Source§impl Clone for NetCounters
impl Clone for NetCounters
impl Copy for NetCounters
Source§impl Debug for NetCounters
impl Debug for NetCounters
Source§impl Default for NetCounters
impl Default for NetCounters
impl Eq for NetCounters
Source§impl PartialEq for NetCounters
impl PartialEq for NetCounters
impl StructuralPartialEq for NetCounters
Auto Trait Implementations§
impl Freeze for NetCounters
impl RefUnwindSafe for NetCounters
impl Send for NetCounters
impl Sync for NetCounters
impl Unpin for NetCounters
impl UnsafeUnpin for NetCounters
impl UnwindSafe for NetCounters
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more