13 releases (5 stable)

1.2.1 Mar 10, 2020
1.1.1 Jan 23, 2020
1.1.0 Dec 2, 2019
1.0.1 Aug 3, 2019
0.2.0 Mar 12, 2016

#4 in Hardware support

Download history 220/week @ 2019-12-10 278/week @ 2019-12-17 441/week @ 2019-12-24 520/week @ 2019-12-31 586/week @ 2020-01-07 332/week @ 2020-01-14 300/week @ 2020-01-21 188/week @ 2020-01-28 510/week @ 2020-02-04 560/week @ 2020-02-11 394/week @ 2020-02-18 1201/week @ 2020-02-25 918/week @ 2020-03-03 752/week @ 2020-03-10 737/week @ 2020-03-17 890/week @ 2020-03-24

2,185 downloads per month
Used in 62 crates (27 directly)

MIT license

225KB
5.5K SLoC

C 3.5K SLoC // 0.2% comments Visual Studio Project 1K SLoC Rust 669 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 by signal11. 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