Closed spookyvision closed 4 weeks ago
Great work! I was able to use this to make a simple POC ping example with a minimal effort webusb "wire" implementation using web_sys in Rust.
One thing regarding the dioxus dependency. I'm not familiar with the framework at all, I'm just serving very simple HTML/JS with webpack as a POC. Using wasm_bindgen_futures::spawn_local works just fine in that context.
@dingari cool! My most recent commit also adds a wire implementation to relieve users of that implementation burden 😬 The dioxus dependency is required iff one is using dioxus, but the good news is that spawning can easily be delegated to a feature flag. However I'm not 100% happy with the way spawning is handled now (as per my latest commit, which moves prpc towards more code reuse regarding different wire backends), and have already raised this with James.
Awesome, works great!
For now, we just wrap WebUsbClient
and impl Client
on it to delegate spawning to wasm_bindgen_futures::spawn_local
instead of dioxus::spawn
.
good news, we don't need Dioxus anymore after all! an old version of my driver was using Dioxus signals to store state and that's probably what required the global Dioxus context. All gone now!
(this text will be edited, further discussion needed)currently this PR adds support for something that is vaguely shaped like WebUSB, however:- the actual WebUSB-specific part isn't done inside this repo (and maybe shouldn't be) - the implementation is rather generic and can probably be merged with nusb- there is a dependency ondioxus::spawn
which violates separation of concerns in 2 ways - 1. dioxus should IMHO not be a dependency of prpc, even behind a feature gate, 2. Dioxus is orthogonal to WebUSB. WASM prpc apps without Dioxus are totally possible, but Dioxus apps require to run inside the Dioxus scope. The solution to that would probably be something like a genericSpawner
field onHostClient
. But I don't want to start working on that before we've answererd the question of how to use async traits instead ofHostClient::new_manual
.this PR adds a
Client
trait to implement a wire protocol backend, associated helper functionality forHostClient
, and a WebUSB implementation ofClient
.