#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 540/week @ 2019-11-10 223/week @ 2019-11-17 216/week @ 2019-11-24 216/week @ 2019-12-01 220/week @ 2019-12-08 250/week @ 2019-12-15 373/week @ 2019-12-22 557/week @ 2019-12-29 378/week @ 2020-01-05 570/week @ 2020-01-12 295/week @ 2020-01-19 232/week @ 2020-01-26 421/week @ 2020-02-02 518/week @ 2020-02-09 420/week @ 2020-02-16

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