Skip to main content

Crate nic_port_info

Crate nic_port_info 

Source
Expand description

The crate provides a way to get the link information of the NIC, including the port type, supported modes. The crate is based on the ioctl command, so it can only be used on Linux.

§Examples

List all the NICs’ port information.

use ethtool::get_nic_port_info;
let nics_port = get_nic_port_info(None);
for nic_port in nics_port {
   println!("NIC: {}", nic_port.name());
   println!("Port: {}", nic_port.port());
   println!("Supported: {:?}", nic_port.supported());
}

Get the port information of the specified NIC.

use ethtool::get_nic_port_info;
let nics_port = get_nic_port_info(Some("eth0"));
for nic_port in nics_port {
  println!("NIC: {}", nic_port.name());
  println!("Port: {}", nic_port.port());
  println!("Supported: {:?}", nic_port.supported());
}

Get the port information of the specified NIC by PortInfo.

use ethtool::PortInfo;
let nic_port = PortInfo::from_name("eth0").unwrap();
println!("NIC: {}", nic_port.name());
println!("Port: {}", nic_port.port());
println!("Supported: {:?}", nic_port.supported());

Structs§

EthtoolError
PortInfo
The port information includes the port type, supported modes.

Functions§

get_nic_port_info
Get the port information of the NIC If devname is None, get all the NICs’ port information. If devname is Some(&str), get the specified NIC’s port information.