X-Git-Url: https://code.octet-stream.net/netwatcher/blobdiff_plain/d2c9a9f306a336aa9dd8ddfb6579746e4f10b7a4..473c9605820f4531f9d40823338fa4bf8718dd6f:/src/list_unix.rs diff --git a/src/list_unix.rs b/src/list_unix.rs index fad4306..a7cd881 100644 --- a/src/list_unix.rs +++ b/src/list_unix.rs @@ -13,11 +13,12 @@ struct CandidateInterface { } pub(crate) fn list_interfaces() -> Result { - let addrs = getifaddrs().map_err(|_| Error::Internal)?; + let addrs = getifaddrs().map_err(|e| Error::Getifaddrs(e))?; let mut candidates = HashMap::new(); for addr in addrs { - let index = if_nametoindex(addr.interface_name.as_str()).map_err(|_| Error::Internal)?; + let index = + if_nametoindex(addr.interface_name.as_str()).map_err(|e| Error::GetInterfaceName(e))?; let candidate = candidates .entry(addr.interface_name.clone()) .or_insert_with(|| CandidateInterface { @@ -64,9 +65,9 @@ fn format_mac(bytes: &[u8]) -> Result { let mut mac = String::with_capacity(bytes.len() * 3); for (i, b) in bytes.iter().enumerate() { if i != 0 { - write!(mac, ":").map_err(|_| Error::Internal)?; + write!(mac, ":").map_err(|_| Error::FormatMacAddress)?; } - write!(mac, "{:02X}", b).map_err(|_| Error::Internal)?; + write!(mac, "{:02X}", b).map_err(|_| Error::FormatMacAddress)?; } Ok(mac) }