]> code.octet-stream.net Git - netwatcher/blob - src/util.rs
List interfaces on Mac
[netwatcher] / src / util.rs
1 use crate::Error;
2 use std::fmt::Write;
3
4 pub(crate) fn format_mac(bytes: &[u8]) -> Result<String, Error> {
5 let mut mac = String::with_capacity(bytes.len() * 3);
6 for i in 0..bytes.len() {
7 if i != 0 {
8 write!(mac, ":").map_err(|_| Error::Internal)?;
9 }
10 write!(mac, "{:02X}", bytes[i]).map_err(|_| Error::Internal)?;
11 }
12 Ok(mac)
13 }