Debian Codegraph @

examples/detach.rs

raw symbols SCIP
1 //! Detach the kernel driver for an FTDI device and then reattach it.
2 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#};
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 let di = nusbrust-analyzer cargo nusb 0.1.13 crate/::list_devicesrust-analyzer cargo nusb 0.1.13 list_devices().()
6 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
7 .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().0x6001)
8 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("device should be connected");
9
10 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().();
11 device.detach_kernel_driverrust-analyzer cargo nusb 0.1.13 device/impl#[Device]detach_kernel_driver().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
12 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().(10));
13 device.attach_kernel_driverrust-analyzer cargo nusb 0.1.13 device/impl#[Device]attach_kernel_driver().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
14 }