Expand description
WebUSB on the web 🕸️ — Access USB devices from the web browser.
The WebUSB API provides a way to expose non-standard Universal Serial Bus (USB) compatible devices services to the web, to make USB safer and easier to use.
This crate provides Rust support for using WebUSB when targeting WebAssembly.
MDN provides a WebUSB overview while detailed information is available in the WebUSB specification.
§Building
This crate depends on unstable features of the web_sys
crate.
Therefore you must add --cfg=web_sys_unstable_apis
to the Rust
compiler flags (RUSTFLAGS
).
§Usage
Call Usb::new()
to obtain an interface to the WebUSB API.
You must call Usb::request_device()
to ask the user for permission before
any USB device can be used through this API.
Structs§
- Error
- WebUSB error.
- Open
UsbDevice - An opened USB device.
- Usb
- WebUSB device enumeration and connection.
- UsbAlternate
Interface - An alternate setting containing detailed interface information.
- UsbConfiguration
- A configuration belonging to a USB device.
- UsbControl
Request - USB control request.
- UsbDevice
- A USB device.
- UsbDevice
Filter - A filter used to match specific USB devices by various criteria.
- UsbEndpoint
- A USB endpoint provided by the USB device.
- UsbEvents
- WebUSB event stream.
- UsbInterface
- A USB interface grouping one or more alternate settings.
Enums§
- Error
Kind - WebUSB error kind.
- UsbDirection
- USB transfer direction.
- UsbEndpoint
Type - USB endpoint type.
- UsbEvent
- WebUSB event.
- UsbRecipient
- The recipient of a USB control transfer.
- UsbRequest
Type - The type of USB control request.
Type Aliases§
- Result
- WebUSB result.