Bumped version of nusb, improved docs

This commit is contained in:
G2-Games 2024-01-31 14:03:09 -06:00
parent 0ffcbeee5f
commit d9bf9a6a75
3 changed files with 35 additions and 4 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "cross_usb"
version = "0.1.0"
version = "0.1.1"
authors = ["G2-Games <ke0bhogsg@gmail.com>"]
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"

View file

@ -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

View file

@ -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"))]