Fixed typos

This commit is contained in:
G2-Games 2024-03-24 06:41:08 -05:00
parent 35ed1e273b
commit 43e19eda94
2 changed files with 31 additions and 17 deletions

View file

@ -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/) //! 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). //! 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: //! ### CURRENT LIMITATIONS:
//! * Hotplug support is not implemented. Waiting on [hotplug support in nusb](https://github.com/kevinmehall/nusb/pull/20). //! * Hotplug support is not implemented. Waiting on [hotplug support in nusb](https://github.com/kevinmehall/nusb/pull/20).
@ -19,7 +19,8 @@
//! ## Example: //! ## Example:
//! ```no_run //! ```no_run
//! # tokio_test::block_on(async { //! # 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; //! use cross_usb::device_filter;
//! //!
//! // Obtain a device descriptor using a DeviceFilter, //! // Obtain a device descriptor using a DeviceFilter,
@ -51,6 +52,18 @@
//! ``` //! ```
pub mod usb; 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 /// The context contains the platform specific implementation of the USB transfers
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
#[path = "./backend/native.rs"] #[path = "./backend/native.rs"]
@ -61,11 +74,12 @@ mod context;
mod context; mod context;
#[doc(inline)] #[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; pub use crate::context::Descriptor;
#[doc(inline)] #[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; pub use crate::context::Device;
#[doc(inline)] #[doc(inline)]
@ -77,7 +91,7 @@ pub use crate::context::Interface;
#[doc(inline)] #[doc(inline)]
pub use crate::context::DeviceFilter; 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 /// and ProductIDs
/// ///
/// ## Example /// ## Example
@ -90,13 +104,13 @@ pub use crate::context::DeviceFilter;
/// device_filter!{vendor_id: 0x054c}, /// 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)] #[doc(inline)]
pub use crate::context::get_device; 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 /// ## Example
/// ```no_run /// ```no_run
@ -108,7 +122,7 @@ pub use crate::context::get_device;
/// device_filter!{vendor_id: 0x054c}, /// 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... */ /// /* 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. /// 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 /// 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 /// ## Usage
/// ``` /// ```
@ -129,11 +143,11 @@ pub use crate::context::get_device_list;
/// ///
/// // Example with all fields filled /// // Example with all fields filled
/// device_filter!{ /// device_filter!{
/// vendor_id: 0x054c, /// vendor_id: 0x054c, // u16
/// product_id: 0x0186, /// product_id: 0x0186, // u16
/// class: 0xFF, /// class: 0xFF, // u8
/// subclass: 0x02, /// subclass: 0x02, // u8
/// protocol: 0x15, /// protocol: 0x15, // u8
/// }; /// };
/// ``` /// ```
#[macro_export] #[macro_export]

View file

@ -141,7 +141,7 @@ pub enum Recipient {
Other = 3, Other = 3,
} }
/// Parameters for [Interface::control_in] /// Parameters for [UsbInterface::control_in]
pub struct ControlIn { pub struct ControlIn {
pub control_type: ControlType, pub control_type: ControlType,
pub recipient: Recipient, pub recipient: Recipient,
@ -151,7 +151,7 @@ pub struct ControlIn {
pub length: u16, pub length: u16,
} }
/// Parameters for [Interface::control_out] /// Parameters for [UsbInterface::control_out]
pub struct ControlOut<'a> { pub struct ControlOut<'a> {
pub control_type: ControlType, pub control_type: ControlType,
pub recipient: Recipient, pub recipient: Recipient,