#[non_exhaustive]pub struct TrafficCounters {
pub bytes_sent: u64,
pub bytes_received: u64,
pub packets_sent: u64,
pub packets_received: u64,
pub packets_dropped: u64,
pub errors: u64,
}Expand description
Traffic counters for a single interface.
Tier: T2-P (N Quantity — byte counts)
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.bytes_sent: u64Bytes sent.
bytes_received: u64Bytes received.
packets_sent: u64Packets sent.
packets_received: u64Packets received.
packets_dropped: u64Packets dropped (send failures).
errors: u64Errors encountered.
Implementations§
Source§impl TrafficCounters
impl TrafficCounters
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Total bytes (sent + received).
Sourcepub fn total_packets(&self) -> u64
pub fn total_packets(&self) -> u64
Total packets (sent + received).
Sourcepub fn packet_loss_rate(&self) -> f64
pub fn packet_loss_rate(&self) -> f64
Packet loss rate (0.0 - 1.0).
Sourcepub fn record_sent(&mut self, bytes: u64)
pub fn record_sent(&mut self, bytes: u64)
Record bytes sent.
Sourcepub fn record_received(&mut self, bytes: u64)
pub fn record_received(&mut self, bytes: u64)
Record bytes received.
Sourcepub fn record_dropped(&mut self)
pub fn record_dropped(&mut self)
Record a dropped packet.
Sourcepub fn record_error(&mut self)
pub fn record_error(&mut self)
Record an error.
Sourcepub fn bytes_sent_human(&self) -> String
pub fn bytes_sent_human(&self) -> String
Human-readable byte count.
Sourcepub fn bytes_received_human(&self) -> String
pub fn bytes_received_human(&self) -> String
Human-readable byte count.
Trait Implementations§
Source§impl Clone for TrafficCounters
impl Clone for TrafficCounters
Source§fn clone(&self) -> TrafficCounters
fn clone(&self) -> TrafficCounters
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 TrafficCounters
impl Debug for TrafficCounters
Source§impl Default for TrafficCounters
impl Default for TrafficCounters
Source§fn default() -> TrafficCounters
fn default() -> TrafficCounters
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TrafficCounters
impl<'de> Deserialize<'de> for TrafficCounters
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TrafficCounters
impl RefUnwindSafe for TrafficCounters
impl Send for TrafficCounters
impl Sync for TrafficCounters
impl Unpin for TrafficCounters
impl UnsafeUnpin for TrafficCounters
impl UnwindSafe for TrafficCounters
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