15 releases (7 stable)

1.2.3 Jun 26, 2020
1.2.1 Mar 10, 2020
1.1.0 Dec 2, 2019
1.0.1 Aug 3, 2019
0.2.0 Mar 12, 2016

#3 in Hardware support

Download history 605/week @ 2020-03-16 1037/week @ 2020-03-23 877/week @ 2020-03-30 670/week @ 2020-04-06 1134/week @ 2020-04-13 597/week @ 2020-04-20 723/week @ 2020-04-27 639/week @ 2020-05-04 1214/week @ 2020-05-11 1165/week @ 2020-05-18 1122/week @ 2020-05-25 1198/week @ 2020-06-01 1546/week @ 2020-06-08 827/week @ 2020-06-15 780/week @ 2020-06-22 1092/week @ 2020-06-29

4,116 downloads per month
Used in 73 crates (33 directly)

MIT license

225KB
5.5K SLoC

C 3.5K SLoC // 0.2% comments Visual Studio Project 1K SLoC Rust 678 SLoC // 0.2% comments C++ 408 SLoC // 0.1% comments Automake 158 SLoC // 0.0% comments Objective-C 70 SLoC // 0.1% comments Visual Studio Solution 61 SLoC Shell 55 SLoC // 0.3% comments

hidapi Build Status Version License: MIT Documentation Chat

This crate provides a rust abstraction over the features of the C library hidapi. Based off of hidapi-rs by Osspial.

Usage

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

Example

extern crate hidapi;

let api = hidapi::HidApi::new().unwrap();
// Print out information about all connected devices
for device in api.devices() {
    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