Skip to content

Commit

Permalink
Reorder and left-align output of list_ports for readability
Browse files Browse the repository at this point in the history
This helps (at least me) a lot for faster visual navigation through the
output of this example.
  • Loading branch information
sirhcel committed Oct 14, 2024
1 parent 5a1a940 commit b7e67e4
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions examples/list_ports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,40 @@ fn main() {
n => println!("Found {} ports:", n),
};
for p in ports {
println!(" {}", p.port_name);
println!(" {}", p.port_name);
match p.port_type {
SerialPortType::UsbPort(info) => {
println!(" Type: USB");
println!(" VID:{:04x} PID:{:04x}", info.vid, info.pid);
println!(" Type: USB");
println!(" VID: {:04x}", info.vid);
println!(" PID: {:04x}", info.pid);
#[cfg(feature = "usbportinfo-interface")]
println!(
" Interface: {}",
info.interface
.as_ref()
.map_or("".to_string(), |x| format!("{:02x}", *x))
);
println!(
" Serial Number: {}",
" Serial Number: {}",
info.serial_number.as_ref().map_or("", String::as_str)
);
println!(
" Manufacturer: {}",
" Manufacturer: {}",
info.manufacturer.as_ref().map_or("", String::as_str)
);
println!(
" Product: {}",
" Product: {}",
info.product.as_ref().map_or("", String::as_str)
);
#[cfg(feature = "usbportinfo-interface")]
println!(
" Interface: {}",
info.interface
.as_ref()
.map_or("".to_string(), |x| format!("{:02x}", *x))
);
}
SerialPortType::BluetoothPort => {
println!(" Type: Bluetooth");
println!(" Type: Bluetooth");
}
SerialPortType::PciPort => {
println!(" Type: PCI");
println!(" Type: PCI");
}
SerialPortType::Unknown => {
println!(" Type: Unknown");
println!(" Type: Unknown");
}
}
}
Expand Down

0 comments on commit b7e67e4

Please sign in to comment.