Trait libmacchina::traits::NetworkReadout [−][src]
pub trait NetworkReadout {
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
This function should return the number of bytes transmitted by the interface of the host.
fn 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.
This function should return the number of bytes received by the interface of the host.
fn 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.
fn 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 addess, i.e. local IPv4/6 address of the specified interface.
e.g. 192.168.1.2
fn 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