#hid #api #usb #binding #wrapper

sys hidapi

Rust-y wrapper around hidapi

11 releases (3 stable)

1.1.1 Jan 23, 2020
1.1.0 Dec 2, 2019
1.0.1 Aug 3, 2019
1.0.0 Jul 31, 2019
0.2.0 Mar 12, 2016

#6 in Hardware support

Download history 457/week @ 2019-11-07 213/week @ 2019-11-14 269/week @ 2019-11-21 139/week @ 2019-11-28 272/week @ 2019-12-05 218/week @ 2019-12-12 329/week @ 2019-12-19 627/week @ 2019-12-26 310/week @ 2020-01-02 636/week @ 2020-01-09 281/week @ 2020-01-16 308/week @ 2020-01-23 186/week @ 2020-01-30 573/week @ 2020-02-06 465/week @ 2020-02-13

1,335 downloads per month
Used in 62 crates (26 directly)

MIT license

220KB
5.5K SLoC

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