Trait libmacchina::traits::NetworkReadout
source · pub trait NetworkReadout {
// Required methods
fn new() -> Self;
fn tx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>;
fn tx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>;
fn rx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>;
fn rx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>;
fn logical_address(
&self,
interface: Option<&str>
) -> Result<String, ReadoutError>;
fn physical_address(
&self,
interface: Option<&str>
) -> Result<String, ReadoutError>;
}
Expand description
This trait provides an interface to various networking statistics about the host system.
§Example
use libmacchina::traits::NetworkReadout;
use libmacchina::traits::ReadoutError;
pub struct MacOSNetworkReadout;
impl NetworkReadout for MacOSNetworkReadout {
fn new() -> Self {
MacOSNetworkReadout {}
}
fn tx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError> {
todo!()
}
fn tx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError> {
todo!()
}
fn rx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError> {
todo!()
}
fn rx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError> {
todo!()
}
fn logical_address(&self, interface: Option<&str>) -> Result<String, ReadoutError> {
todo!()
}
fn physical_address(&self, interface: Option<&str>) -> Result<String, ReadoutError> {
todo!()
}
}
Required Methods§
sourcefn tx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
fn tx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
This function should return the number of bytes transmitted by the interface of the host.
sourcefn tx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
fn tx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
This function should return the number of packets transmitted by the interface of the host.
sourcefn rx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
fn rx_bytes(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
This function should return the number of bytes received by the interface of the host.
sourcefn rx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
fn rx_packets(&self, interface: Option<&str>) -> Result<usize, ReadoutError>
This function should return the number of packets received by the interface of the host.
sourcefn logical_address(
&self,
interface: Option<&str>
) -> Result<String, ReadoutError>
fn logical_address( &self, interface: Option<&str> ) -> Result<String, ReadoutError>
This function should return the logical address, i.e. local IPv4/6 address of the specified interface.
e.g. 192.168.1.2
sourcefn physical_address(
&self,
interface: Option<&str>
) -> Result<String, ReadoutError>
fn physical_address( &self, interface: Option<&str> ) -> Result<String, ReadoutError>
This function should return the physical address, i.e. MAC address of the specified interface.
e.g. 52:9a:d2:d3:b5:fd
Object Safety§
This trait is not object safe.