Conversation
|
Personally I would completely forego blocking variants of those methods and make all of them async. The readme states |
|
The But then it seems kind of silly to do what is effectively |
3986e70 to
8532a37
Compare
`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 `IoAction` trait allows defering 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.
8532a37 to
a4662e6
Compare
|
Fair point :) That's actually a really nice way to do this :) I think we can merge this as is :) |
|
How are we looking on this? :) I would love to round up my WebUSB backend PR :) |
9ff6180 to
11b8fe4
Compare
|
Renamed it, but I think it's ready. |
DeviceInfo::open,Device::from_fd,Device::set_configuration,Device::reset,Interface::set_alt_setting,Interface::clear_haltall perform IO but are currently blocking because the underlying OS APIs are blocking.list_devices,list_buses,Device::claim_interfaceDevice::detach_and_claim_interfacetheoretically don't perform IO, but are also included here because they need to be async on WebUSB.The
IoActiontrait allows defering these actions to the thread pool from theblockingcrate when used asynchronously with.await/IntoFuture, or directly runs the blocking syscall synchronously with a.wait()method.Open question: Should the dependency on
blockingbe behind a cargo feature, and if unset, shouldIoActionnot implIntoFutureor should it return a dummy Future that runs synchronously?