diff --git a/Cargo.toml b/Cargo.toml index 2f75c30..62fa13a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cross_usb" -version = "0.1.0" +version = "0.1.1" authors = ["G2-Games "] repository = "https://github.com/G2-Games/cross-usb" documentation = "https://docs.rs/cross_usb" @@ -46,6 +46,9 @@ features = [ [target.'cfg(not(target_family = "wasm"))'.dependencies] nusb = "0.1.5" +[dev-dependencies] +futures-lite = "1.13.0" + [profile.release] opt-level = "s" diff --git a/src/backend/wasm.rs b/src/backend/wasm.rs index aeb940c..90221e3 100644 --- a/src/backend/wasm.rs +++ b/src/backend/wasm.rs @@ -5,9 +5,8 @@ use wasm_bindgen::prelude::*; use js_sys::{Array, Object, Promise, Uint8Array}; use wasm_bindgen_futures::JsFuture; use web_sys::{ - console, UsbControlTransferParameters, UsbDevice as WasmUsbDevice, - UsbDeviceRequestOptions, UsbInTransferResult, - UsbOutTransferResult, UsbRecipient, UsbRequestType, + console, UsbControlTransferParameters, UsbDevice as WasmUsbDevice, UsbDeviceRequestOptions, + UsbInTransferResult, UsbOutTransferResult, UsbRecipient, UsbRequestType, }; // Crate stuff diff --git a/src/lib.rs b/src/lib.rs index 6bc343a..f0393b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,32 @@ +#![warn(missing_docs)] +//! Cross USB is a USB library which works seamlessly across native and WASM targets. +//! +//! The idea is the user only has to write one way to access USB devices, which can be compiled +//! to both WASM and native targets without any conditional compilation or configuration. +//! +//! ## Example: +//! ```no_run +//! use cross_usb::usb::{Device, Recipient, ControlType, ControlIn}; +//! +//! // Obtain a device using its VendorID and ProductID +//! let device = cross_usb::get_device(0x054c, 0x0186).await.expect(""); +//! +//! // Obtain an interface of the device +//! let interface = usb_device.open_interface(0).await.expect("Failed to open interface"); +//! +//! // Send a Control transfer to the device, obtaining +//! // the result and storing it in `result`, and you're done! +//! let result = match interface.control_in(ControlIn { +//! control_type: ControlType::Vendor, +//! recipient: Recipient::Interface, +//! request: 0x01, +//! value: 0, +//! index: 0, +//! length: 4, +//! }) +//! .await +//! .expect("Sending control transfer failed"); +//! ``` pub mod usb; #[cfg(not(target_family = "wasm"))]