Crate rusb

source · []
Expand description

This crate provides a safe wrapper around the native libusb library.


pub use libusb1_sys as ffi;



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.

A libusb runtime option that can be enabled for a context.

A three-part version consisting of major, minor, and sub minor components.


Transfer and endpoint directions.

Errors returned by the libusb library.

Library logging levels.

Primary language families.

Recipients of control transfers.

Types of control transfers.

Device speeds. Indicates the speed at which a device is operating.

Language dialects and writing systems.

Isochronous synchronization mode.

An endpoint’s transfer type.

Isochronous usage type.


When handling a Hotplug::device_arrived event it is considered safe to call any rusb function that takes a Device. It also safe to open a device and submit asynchronous transfers. However, most other functions that take a DeviceHandle 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.


Returns a list of the current USB devices. Using global context

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 Definitions

A result of a function that may return a Error.