#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Serialize, Deserialize)]
pub enum NetworkPortIdentifier
{
ByPciDeviceAddress(DeviceAddress),
ByNetworkInterfaceName(NetworkInterfaceName),
}
impl NetworkPortIdentifier
{
pub fn toPciDevice(&self, sysPath: &Path) -> PciDevice
{
let deviceAddress = match *self
{
NetworkPortIdentifier::ByPciDeviceAddress(deviceAddress) => deviceAddress.clone(),
NetworkPortIdentifier::ByNetworkInterfaceName(ref networkInterfaceName) => networkInterfaceName.pciDeviceAddress().expect("Could not parse PCI device address string").expect(&format!("No valid PCI device for interface '{:?}'", networkInterfaceName))
};
let pciDevice = PciDevice(deviceAddress);
assert!(pciDevice.isClassNetworkEthernet(sysPath), "PCI device '{:?}' for networkPortIdentifier '{:?}' is for not an Ethernet class PCI device (or does not exist at all)", pciDevice, self);
pciDevice
}
}