From 43e19eda944ab5c9de1c9d7a3fa3fb24059975c6 Mon Sep 17 00:00:00 2001 From: G2-Games Date: Sun, 24 Mar 2024 06:41:08 -0500 Subject: [PATCH] Fixed typos --- src/lib.rs | 44 +++++++++++++++++++++++++++++--------------- src/usb.rs | 4 ++-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d377bbe..f18a3e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ //! and comparable to the very popular `libusb` C library. Web Assembly support is provided by [web-sys](https://docs.rs/web-sys/latest/web_sys/) //! with the [Web USB API](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API). //! -//! When a [`UsbInterface`] is dropped, it is automatically released. +//! When an [`Interface`] is dropped, it is automatically released. //! //! ### CURRENT LIMITATIONS: //! * Hotplug support is not implemented. Waiting on [hotplug support in nusb](https://github.com/kevinmehall/nusb/pull/20). @@ -19,7 +19,8 @@ //! ## Example: //! ```no_run //! # tokio_test::block_on(async { -//! use cross_usb::usb::{UsbDescriptor, UsbDevice, UsbInterface, Recipient, ControlType, ControlIn}; +//! use cross_usb::prelude::*; +//! use cross_usb::usb::{Recipient, ControlType, ControlIn}; //! use cross_usb::device_filter; //! //! // Obtain a device descriptor using a DeviceFilter, @@ -51,6 +52,18 @@ //! ``` pub mod usb; +/// This prelude imports all the necessary traits needed to actually use USB +/// devices and interfaces. +/// +/// ``` +/// use cross_usb::prelude::*; +/// ``` +pub mod prelude { + pub use crate::usb::UsbDescriptor; + pub use crate::usb::UsbDevice; + pub use crate::usb::UsbInterface; +} + /// The context contains the platform specific implementation of the USB transfers #[cfg(not(target_family = "wasm"))] #[path = "./backend/native.rs"] @@ -61,11 +74,12 @@ mod context; mod context; #[doc(inline)] -/// An implementation of a USB device descriptor +/// A descriptor of a USB device, containing information about a device +/// without claiming it pub use crate::context::Descriptor; #[doc(inline)] -/// A USB device, you must open a [`UsbInterface`] to perform transfers +/// A USB device, you must open an [`Interface`] to perform transfers pub use crate::context::Device; #[doc(inline)] @@ -77,7 +91,7 @@ pub use crate::context::Interface; #[doc(inline)] pub use crate::context::DeviceFilter; -/// Gets a single (the first found) [`UsbDescriptor`] from a list of VendorID +/// Gets a single (the first found) device as a [`Descriptor`] from a list of VendorID /// and ProductIDs /// /// ## Example @@ -90,13 +104,13 @@ pub use crate::context::DeviceFilter; /// device_filter!{vendor_id: 0x054c}, /// ]; /// -/// let device = get_device(filter).await.expect("Could not find device in list"); +/// let device = get_device(filter).await.expect("Could not find device matching filters"); /// # }) /// ``` #[doc(inline)] pub use crate::context::get_device; -/// Gets a list of [`UsbDescriptor`]s from a list of VendorID and ProductIDs +/// Gets a list of [`Descriptor`]s from a list of VendorID and ProductIDs /// /// ## Example /// ```no_run @@ -108,7 +122,7 @@ pub use crate::context::get_device; /// device_filter!{vendor_id: 0x054c}, /// ]; /// -/// let device_list = get_device_list(filter).await.expect("Could not find device in list"); +/// let device_list = get_device_list(filter).await.expect("Could not find device matching filters"); /// /// /* Do something with the list of devices... */ /// # }) @@ -119,9 +133,9 @@ pub use crate::context::get_device_list; /// Macro to create a device filter more easily. /// -/// The only valid keys are fields of the [DeviceFilter] struct. +/// The only valid keys are fields of the [`DeviceFilter`] struct. /// You may use as many or as few of them as you need, the rest -/// of the values will be filled with [None]. +/// of the values will be filled with [`None`]. /// /// ## Usage /// ``` @@ -129,11 +143,11 @@ pub use crate::context::get_device_list; /// /// // Example with all fields filled /// device_filter!{ -/// vendor_id: 0x054c, -/// product_id: 0x0186, -/// class: 0xFF, -/// subclass: 0x02, -/// protocol: 0x15, +/// vendor_id: 0x054c, // u16 +/// product_id: 0x0186, // u16 +/// class: 0xFF, // u8 +/// subclass: 0x02, // u8 +/// protocol: 0x15, // u8 /// }; /// ``` #[macro_export] diff --git a/src/usb.rs b/src/usb.rs index cc897aa..4f0b023 100644 --- a/src/usb.rs +++ b/src/usb.rs @@ -141,7 +141,7 @@ pub enum Recipient { Other = 3, } -/// Parameters for [Interface::control_in] +/// Parameters for [UsbInterface::control_in] pub struct ControlIn { pub control_type: ControlType, pub recipient: Recipient, @@ -151,7 +151,7 @@ pub struct ControlIn { pub length: u16, } -/// Parameters for [Interface::control_out] +/// Parameters for [UsbInterface::control_out] pub struct ControlOut<'a> { pub control_type: ControlType, pub recipient: Recipient,