Debian Codegraph @

examples/descriptors.rs

raw symbols SCIP
1 use nusbrust-analyzer cargo nusb 0.1.13 crate/::DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#;
2
3 fn mainrust-analyzer cargo nusb 0.1.13 main().() {
4 env_loggerrust-analyzer cargo env_logger 0.11.11 crate/::initrust-analyzer cargo env_logger 0.11.11 logger/init().();
5 for dev in nusbrust-analyzer cargo nusb 0.1.13 crate/::list_devicesrust-analyzer cargo nusb 0.1.13 list_devices().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() {
6 inspect_devicerust-analyzer cargo nusb 0.1.13 inspect_device().(dev);
7 }
8 }
9
10 fn inspect_devicerust-analyzer cargo nusb 0.1.13 inspect_device().(dev: DeviceInforust-analyzer cargo nusb 0.1.13 enumeration/DeviceInfo#) {
11 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!(
12 "Device {:03}.{:03} ({:04x}:{:04x}) {} {}",
13 dev.bus_numberrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]bus_number().(),
14 dev.device_addressrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]device_address().(),
15 dev.vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]vendor_id().(),
16 dev.product_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]product_id().(),
17 dev.manufacturer_stringrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]manufacturer_string().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(""),
18 dev.product_stringrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]product_string().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().("")
19 );
20 let dev = match dev.openrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]open().() {
21 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(dev) => dev,
22 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => {
23 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Failed to open device: {}", e);
24 return;
25 }
26 };
27
28 match dev.active_configurationrust-analyzer cargo nusb 0.1.13 device/impl#[Device]active_configuration().() {
29 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(config) => printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Active configuration is {}", config.configuration_valuerust-analyzer cargo nusb 0.1.13 descriptors/impl#[`Configuration<'a>`]configuration_value().()),
30 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Unknown active configuration: {e}"),
31 }
32
33 for config in dev.configurationsrust-analyzer cargo nusb 0.1.13 device/impl#[Device]configurations().() {
34 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{config:#?}");
35 }
36 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("");
37 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("");
38 }