Expand description
This crate provides a safe wrapper around the native libusb
library.
Yet another fork of a fork of a Rust libusb wrapper!
This is a fork of Ilya Averyanov’s rusb crate, which itself is a fork of David Cuddeback’s libusb crate.
The initial version of this crate differs from rusb
in a number of ways:
- Removes the
UsbContext
trait - The
Device<T>
andDeviceList<T>
no longer need to be generic over theContext
type (since there is now only a single context type), and are now justDevice
andDeviceList
, respectively. - There is a new
Port
type which uniquely identified the physical USB port to which a device in the system is attached.- It is a combination of the bus number and ordered list of hub ports
- This helps to uniquely identify a device when multiple ones are attached with the same VID:PID and no serial number or other distinguishing feature.
- Individual ports are comparable and can be converted to/from strings that use the Linux syspath format, like 2-1.4.3.
- The
Speed
type is updated:- It can be converted to floating-point speed in Mbps, and directly displayed as such.
- It is ordered and comparable like:
if (device.speed() < Speed::Super) { println!("Plug the device into a faster port");
- Some general cleanup and modernization of the code base.
Re-exports
pub use libusb1_sys as ffi;
Modules
Structs
- Describes a configuration.
- A
libusb
context. - A reference to a USB device.
- Describes a device.
- A handle to an open USB device.
- A list of detected USB devices.
- Iterator over detected USB devices.
- Describes an endpoint.
- Iterator over an interface’s endpoint descriptors.
- Builds hotplug Registration with custom configuration values.
- A device interface.
- Describes an alternate setting for an interface.
- Iterator over an interface’s descriptors.
- Iterator over a configuration’s interfaces.
- A language used to read string descriptors from USB devices.
- A structure that describes the version of the underlying
libusb
library. - The unique port for a USB device.
- Registration object for hotplug callbacks.
- A
libusb
runtime option that can be enabled for a context. - A three-part version consisting of major, minor, and sub minor components.
Enums
- Transfer and endpoint directions.
- Errors returned by the
libusb
library. - Isochronous synchronization mode.
- Usage type for isochronous endpoints. Values for bits 4:5 of the bmAttributes field in the endpoint descriptor.
- Library logging levels.
- Primary language families.
- Recipients of control transfers.
- Types of control transfers.
- Device speeds.
- Language dialects and writing systems.
- An endpoint’s transfer type.
Traits
- When handling a Hotplug::device_arrived event it is considered safe to call any
yusb
function that takes aDevice
. It also safe to open a device and submit asynchronous transfers. However, most other functions that take aDeviceHandle
are not safe to call. Examples of such functions are any of the synchronous API functions or the blocking functions that retrieve various USB descriptors. These functions must be used outside of the context of the Hotplug functions.
Functions
- Returns a list of the current USB devices. Using global context
- Disable device scanning in
libusb
init. - Tests whether the running
libusb
library supports capability API. - Tests whether the running
libusb
library has HID access. - Tests whether the running
libusb
library supports hotplug. - Convenience function to open a device by its vendor ID and product ID. Using global context
- Builds a value for the
bmRequestType
field of a control transfer setup packet. - Sets the log level of a
libusb
global context. - Tests whether the running
libusb
library supports detaching the kernel driver. - Returns a structure with the version of the running libusb library.
Type Aliases
- A result of a function that may return a USB
Error
.