use cli_table::{print_stdout, Cell, Style, Table}; use test_smi_rs::list_devices; use test_smi_rs::SmiResult; fn main() -> SmiResult<()> { let devices = list_devices()?; let mut rows = Vec::with_capacity(devices.len() + 1); let mut header = Vec::with_capacity(devices.len() + 1); header.push("Device".cell().bold(true)); for device in devices.iter() { let name = device.device_info()?.name(); header.push(name.cell().bold(true)); } rows.push(header); for device1 in devices.iter() { let mut row = Vec::with_capacity(devices.len() + 1); row.push(device1.device_info()?.name().cell()); for device2 in devices.iter() { let p2p_accessibility = match device1.p2p_accessible(device2)? { true => "Accessible".to_string(), false => "Inaccessible".to_string(), }; row.push(p2p_accessibility.cell()); } rows.push(row); } let table = rows.table(); print_stdout(table).expect("couldn't print table"); Ok(()) }