• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

examples/25-Apr-2025-567500

src/25-Apr-2025-6,3895,031

Android.bpD25-Apr-202568 21

CHANGELOG.mdD25-Apr-20253.2 KiB8873

Cargo.lockD25-Apr-20257.2 KiB286252

Cargo.tomlD25-Apr-20251.2 KiB5546

Cargo.toml.origD25-Apr-2025761 3125

LICENSED25-Apr-20251.1 KiB2218

METADATAD25-Apr-2025382 2120

MODULE_LICENSE_MITD25-Apr-20250

OWNERSD25-Apr-202565 32

README.mdD25-Apr-20251.9 KiB5542

build.rsD25-Apr-20251 KiB3330

module_block_platform.bp.fragmentD25-Apr-2025311 55

README.md

1# Rusb
2This crate provides a safe wrapper around the native `libusb` library. It applies the RAII pattern
3and Rust lifetimes to ensure safe usage of all `libusb` functionality. The RAII pattern ensures that
4all acquired resources are released when they're no longer needed, and Rust lifetimes ensure that
5resources are released in a proper order.
6
7* [Documentation](https://docs.rs/rusb)
8
9## Dependencies
10To use rusb no extra setup is required as rusb will automatically download the source for libusb and build it.
11
12However if building libusb fails you can also try setting up the native `libusb` library where it can
13be found by `pkg-config` or `vcpkg`.
14
15All systems supported by the native `libusb` library are also supported by the `libusb` crate. It's
16been tested on Linux, OS X, and Windows.
17
18### Cross-Compiling
19The `rusb` crate can be used when cross-compiling to a foreign target. Details on how to
20cross-compile `rusb` are explained in the [`libusb1-sys` crate's
21README](libusb1-sys/README.md#cross-compiling).
22
23## Usage
24Add `rusb` as a dependency in `Cargo.toml`:
25
26```toml
27[dependencies]
28rusb = "0.9"
29```
30
31Import the `rusb` crate. The starting point for nearly all `rusb` functionality is to create a
32context object. With a context object, you can list devices, read their descriptors, open them, and
33communicate with their endpoints:
34
35```rust
36fn main() {
37    for device in rusb::devices().unwrap().iter() {
38        let device_desc = device.device_descriptor().unwrap();
39
40        println!("Bus {:03} Device {:03} ID {:04x}:{:04x}",
41            device.bus_number(),
42            device.address(),
43            device_desc.vendor_id(),
44            device_desc.product_id());
45    }
46}
47```
48
49## License
50Distributed under the [MIT License](LICENSE).
51
52### License note.
53If you link native `libusb` (by example using `vendored` features) library statically then
54you must follow [GNU LGPL](https://github.com/libusb/libusb/blob/master/COPYING) from libusb.
55