A Rust USB library which works on both native and WASM targets
Find a file
2024-07-06 01:23:09 -05:00
.cargo Fixed not compiling on WASM 2024-04-23 11:33:11 -05:00
.github/workflows Updated readme and added proper flags to runner 2024-07-06 01:23:09 -05:00
src Added compile error when web-unstable-apis is not passed 2024-07-06 01:13:52 -05:00
.gitignore Fixed documentation errors 2024-02-08 03:04:49 -06:00
Cargo.toml Added compile error when web-unstable-apis is not passed 2024-07-06 01:13:52 -05:00
LICENSE Added compile error when web-unstable-apis is not passed 2024-07-06 01:13:52 -05:00
README.md Updated readme and added proper flags to runner 2024-07-06 01:23:09 -05:00

Cross USB

Lib.rs Version docs.rs

A USB library which works seamlessly across most native and WASM targets.


Note

Web USB only works in Chromium based browsers for now.

Note

Web USB has certain interation requirements in browsers, along with requiring a Secure context. Please read more about this on the mdn web docs

Important

When compiling this crate on a WASM target, you must use either RUSTFLAGS=--cfg=web_sys_unstable_apis or by passing the argument in a .cargo/config.toml file. Read more here: https://rustwasm.github.io/wasm-bindgen/web-sys/unstable-apis.html

Dependencies

For native USB, the crate utilizies nusb, a pure rust library similar to the very popular libusb.

For WASM, this crate utilizes web-sys which gives access to browser API calls, and in this case is used to interact with WebUSB

TODO

  • Add choice for native backend between libusb wrapper and pure rust nusb
  • Allow platform-specific operations if the user requires them
  • Hot plug support... requires either using libusb as an optional backend or for nusb to implement it