* Make blocking APIs optionally async `DeviceInfo::open`, `Device::from_fd`, `Device::set_configuration`, `Device::reset`, `Interface::set_alt_setting`, `Interface::clear_halt` all perform IO but are currently blocking because the underlying OS APIs are blocking. `list_devices`,`list_buses`, `Device::claim_interface` `Device::detach_and_claim_interface` theoretically don't perform IO, but are also included here because they need to be async on WebUSB. The `MaybeFuture` trait allows deferring these actions to the thread pool from the `blocking` crate when used asynchronously with `.await` / `IntoFuture`, or directly runs the blocking syscall synchronously with a `.wait()` method.
8 lines
154 B
Rust
8 lines
154 B
Rust
use nusb::MaybeFuture;
|
|
|
|
fn main() {
|
|
env_logger::init();
|
|
for dev in nusb::list_devices().wait().unwrap() {
|
|
println!("{:#?}", dev);
|
|
}
|
|
}
|