#hid #api #usb #binding #wrapper

sys hidapi

Rust-y wrapper around hidapi

10 releases (2 stable)

new 1.1.0 Dec 2, 2019
1.0.1 Aug 3, 2019
1.0.0 Jul 31, 2019
0.6.0 Jul 31, 2019
0.2.0 Mar 12, 2016

#10 in Hardware support

Download history 162/week @ 2019-08-19 220/week @ 2019-08-26 272/week @ 2019-09-02 99/week @ 2019-09-09 158/week @ 2019-09-16 123/week @ 2019-09-23 208/week @ 2019-09-30 237/week @ 2019-10-07 360/week @ 2019-10-14 187/week @ 2019-10-21 123/week @ 2019-10-28 185/week @ 2019-11-04 481/week @ 2019-11-11 220/week @ 2019-11-18 211/week @ 2019-11-25

917 downloads per month
Used in 36 crates (22 directly)

MIT license

195KB
5K SLoC

C 3K SLoC // 0.2% comments C++ 632 SLoC // 0.1% comments Visual Studio Project 614 SLoC Rust 527 SLoC // 0.2% comments Automake 158 SLoC // 0.0% comments Objective-C 64 SLoC // 0.1% comments Shell 56 SLoC // 0.3% comments Visual Studio Solution 49 SLoC

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