Debian Codegraph @

examples/detach_claim.rs

raw symbols SCIP
1 //! Detach the kernel driver for an FTDI device, claim the USB interface, and
2 //! then reattach it.
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep()., timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#};
4 fn mainrust-analyzer cargo nusb 0.1.13 main().() {
5 env_loggerrust-analyzer cargo env_logger 0.11.11 crate/::initrust-analyzer cargo env_logger 0.11.11 logger/init().();
6 let di = nusbrust-analyzer cargo nusb 0.1.13 crate/::list_devicesrust-analyzer cargo nusb 0.1.13 list_devices().()
7 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
8 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|d| d.vendor_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]vendor_id().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0x0403 && d.product_idrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]product_id().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0x6010)
9 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("device should be connected");
10
11 let device = di.openrust-analyzer cargo nusb 0.1.13 enumeration/impl#[DeviceInfo]open().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
12 let interface = device.detach_and_claim_interfacerust-analyzer cargo nusb 0.1.13 device/impl#[Device]detach_and_claim_interface().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
13 sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(1));
14 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(interface);
15 }