Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebUSB backend #83

Open
kevinmehall opened this issue Sep 17, 2024 · 2 comments · May be fixed by #99
Open

WebUSB backend #83

kevinmehall opened this issue Sep 17, 2024 · 2 comments · May be fixed by #99
Labels
feature-request New feature or request

Comments

@kevinmehall
Copy link
Owner

https://github.com/G2-Games/cross-usb wraps nusb and WebUSB with a subset of the API, but WebUSB could be an nusb backend in-tree instead of requiring a wrapper library.

This is probably not something I'll get to soon, but the API implications are worth considering, mainly that all WebUSB operations are async, while nusb currently has many blocking methods where the underlying OS operations are blocking.

For non-Wasm, it looks like cross_usb just calls the nusb blocking methods from an async fn, blocking the async runtime. Probably fine for a lot of use cases, but not ideal if your application is primarily async. Doing that right would require depending on blocking or tokio::spawn_blocking. So far nusb has managed to avoid depending on an async executor.

(cc @G2-Games)

@G2-Games
Copy link

G2-Games commented Sep 17, 2024

I thought about looking into including WASM support in nusb originally, but I thought it would be best to do in a separate crate for the moment as my main use case was just a single library I'm working on (minidisc-rs). However, if you're interested in it that's very cool! I'm happy to help or modify my code to be better/work properly, but I haven't looked into the internals of nusb.

As you've already said, WASM cannot block (in an async context), which actually led to the refactoring of the entirety of minidisc-rs to async due to how cross_usb works.

Thank you for your awesome work on nusb!

@TroyNeubauer
Copy link
Contributor

Going to hold off on G2-Games/cross-usb#2 if wasm support is coming to nusb in the near future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants