mirror of
https://github.com/G2-Games/cross-usb.git
synced 2025-04-19 13:22:53 -05:00
32 lines
1.6 KiB
Markdown
32 lines
1.6 KiB
Markdown
# Cross USB
|
|
[](https://lib.rs/crates/cross_usb)
|
|
[](https://docs.rs/cross_usb/)
|
|
|
|
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](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API)
|
|
|
|
> [!IMPORTANT]
|
|
> When compiling this crate on a WASM target, you must use either the rustflags
|
|
> `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](https://github.com/kevinmehall/nusb), a pure rust library similar to the very popular libusb.
|
|
|
|
For WASM, this crate utilizes [web-sys](https://crates.io/crates/web-sys) which gives access to browser API calls, and in this case is used to interact with [WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API)
|
|
|
|
## 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](https://github.com/kevinmehall/nusb/issues/5)
|