Debian Codegraph @

examples/descriptors.rs

raw symbols SCIP
1 use nusb::DeviceInfo;
2
3 fn main() {
4 env_logger::init();
5 for dev in nusb::list_devices().unwrap() {
6 inspect_device(dev);
7 }
8 }
9
10 fn inspect_device(dev: DeviceInfo) {
11 println!(
12 "Device {:03}.{:03} ({:04x}:{:04x}) {} {}",
13 dev.bus_number(),
14 dev.device_address(),
15 dev.vendor_id(),
16 dev.product_id(),
17 dev.manufacturer_string().unwrap_or(""),
18 dev.product_string().unwrap_or("")
19 );
20 let dev = match dev.open() {
21 Ok(dev) => dev,
22 Err(e) => {
23 println!("Failed to open device: {}", e);
24 return;
25 }
26 };
27
28 match dev.active_configuration() {
29 Ok(config) => println!("Active configuration is {}", config.configuration_value()),
30 Err(e) => println!("Unknown active configuration: {e}"),
31 }
32
33 for config in dev.configurations() {
34 println!("{config:#?}");
35 }
36 println!("");
37 println!("");
38 }