4 stable releases

Uses old Rust 2015

1.3.3 Nov 24, 2023
1.3.2 Jun 21, 2022
1.3.1 Apr 2, 2022
1.3.0 Dec 19, 2021

#2212 in Hardware support

Download history 5204/week @ 2024-08-18 6771/week @ 2024-08-25 8331/week @ 2024-09-01 5456/week @ 2024-09-08 5292/week @ 2024-09-15 5623/week @ 2024-09-22 6654/week @ 2024-09-29 7246/week @ 2024-10-06 7071/week @ 2024-10-13 6278/week @ 2024-10-20 5669/week @ 2024-10-27 6594/week @ 2024-11-03 6446/week @ 2024-11-10 8307/week @ 2024-11-17 7423/week @ 2024-11-24 7204/week @ 2024-12-01

29,758 downloads per month
Used in 14 crates (2 directly)

MIT license

275KB
6.5K SLoC

C 4K SLoC // 0.2% comments Visual Studio Project 1K SLoC Rust 788 SLoC // 0.1% comments C++ 408 SLoC // 0.1% comments M4 268 SLoC // 0.4% comments Automake 166 SLoC // 0.0% comments Objective-C 70 SLoC // 0.2% comments Visual Studio Solution 61 SLoC Shell 56 SLoC // 0.3% comments HICAD 36 SLoC Snakemake 2 SLoC // 0.9% comments

Contains (obscure autoconf code, 8KB) etc/hidapi/configure.ac

hidapi-rusb Version License: MIT

This crate provides a rust abstraction over the features of the C library hidapi. Based off of hidapi-rs by ruabmbua. The only difference is that it builds off the libusb coming from rusb. More information: here. If you want to make any contribution, please make them to the ruabmbua repository.

Usage

This crate is on crates.io and can be used by adding hidapi-rusb to the dependencies in your project's Cargo.toml.

Example

extern crate hidapi_rusb;

let api = hidapi_rusb::HidApi::new().unwrap();
// Print out information about all connected devices
for device in api.device_list() {
    println!("{:#?}", device);
}

// Connect to device using its VID and PID
let (VID, PID) = (0x0123, 0x3456);
let device = api.open(VID, PID).unwrap();

// Read data from device
let mut buf = [0u8; 8];
let res = device.read(&mut buf[..]).unwrap();
println!("Read: {:?}", &buf[..res]);

// Write data to device
let buf = [0u8, 1, 2, 3, 4];
let res = device.write(&buf).unwrap();
println!("Wrote: {:?} byte(s)", res);

Documentation

Available at docs.rs.

Dependencies

~0.4–560KB
~12K SLoC