You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

hidapi

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hidapi - cargo Package Compare versions

Comparing version
0.5.2
to
0.6.0
+1
-1
.cargo_vcs_info.json
{
"git": {
"sha1": "3c688160f760be03ad28563defd886a4a942cceb"
"sha1": "98b1d27990cc522306725d29a400895e5d29aa44"
}
}

@@ -6,3 +6,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO

# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
# to registry (e.g., crates.io) dependencies
#

@@ -16,3 +16,3 @@ # If you believe there's an error in this file please file an

name = "hidapi"
version = "0.5.2"
version = "0.6.0"
authors = ["Roland Ruckerbauer <roland.rucky@gmail.com>", "Osspial <osspial@gmail.com>", "Artyom Pavlov <newpavlov@gmail.com>", "mberndt123", "niklasad1"]

@@ -26,8 +26,2 @@ build = "build.rs"

repository = "https://github.com/Osspial/hidapi-rs"
[dependencies.failure]
version = "0.1.2"
[dependencies.failure_derive]
version = "0.1.2"
[dependencies.libc]

@@ -34,0 +28,0 @@ version = "0.2.33"

@@ -10,10 +10,8 @@ /****************************************************************************

extern crate failure;
extern crate hidapi;
use failure::Error;
use hidapi::HidApi;
use hidapi::{HidApi, HidError};
fn main() {
fn run() -> Result<(), Error> {
fn run() -> Result<(), HidError> {
let hidapi = HidApi::new()?;

@@ -40,4 +38,2 @@

}
Ok(())
}

@@ -44,0 +40,0 @@

@@ -1,2 +0,2 @@

# hidapi [![Build Status](https://travis-ci.org/ruabmbua/hidapi-rs.svg?branch=master)](https://travis-ci.org/ruabmbua/hidapi-rs) [![Version](https://img.shields.io/crates/v/hidapi.svg)](https://crates.io/crates/hidapi) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Osspial/hidapi-rs/blob/master/LICENSE.txt) [![Documentation](https://docs.rs/hidapi/badge.svg)](https://docs.rs/hidapi)
# hidapi [![Build Status](https://travis-ci.org/ruabmbua/hidapi-rs.svg?branch=master)](https://travis-ci.org/ruabmbua/hidapi-rs) [![Version](https://img.shields.io/crates/v/hidapi.svg)](https://crates.io/crates/hidapi) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Osspial/hidapi-rs/blob/master/LICENSE.txt) [![Documentation](https://docs.rs/hidapi/badge.svg)](https://docs.rs/hidapi) [![Chat](https://img.shields.io/badge/discord-devroom-blue.svg)](https://discordapp.com/invite/3ahhJGN)

@@ -3,0 +3,0 @@ This crate provides a rust abstraction over the features of the C library

@@ -8,37 +8,60 @@ // **************************************************************************

use super::HidDeviceInfo;
use failure::{Compat, Error};
use libc::wchar_t;
use std::error::Error;
use std::fmt::{Display, Formatter, Result};
#[derive(Debug, Fail)]
#[derive(Debug)]
pub enum HidError {
#[fail(display = "hidapi error: {}", message)]
HidApiError { message: String },
#[fail(
display = "hidapi error: (could not get error message), caused by: {}",
cause
)]
HidApiErrorEmptyWithCause {
#[cause]
cause: Compat<Error>,
},
#[fail(display = "hidapi error: (could not get error message)")]
HidApiErrorEmptyWithCause { cause: Box<Error + Send + Sync> },
HidApiErrorEmpty,
#[fail(display = "failed converting {:#X} to rust char", wide_char)]
FromWideCharError { wide_char: wchar_t },
#[fail(display = "Failed to initialize hidapi (maybe initialized before?)")]
InitializationError,
#[fail(display = "Failed opening hid device")]
OpenHidDeviceError,
#[fail(display = "Invalid data: size can not be 0")]
InvalidZeroSizeData,
#[fail(
display = "Failed to send all data: only sent {} out of {} bytes",
sent,
all
)]
IncompleteSendError { sent: usize, all: usize },
#[fail(display = "Can not set blocking mode to '{}'", mode)]
SetBlockingModeError { mode: &'static str },
#[fail(display = "Can not open hid device with: {:?}", device_info)]
OpenHidDeviceWithDeviceInfoError { device_info: HidDeviceInfo },
}
impl Display for HidError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
HidError::HidApiError { message } => write!(f, "hidapi error: {}", message),
HidError::HidApiErrorEmptyWithCause { cause } => write!(
f,
"hidapi error: (could not get error message), caused by: {}",
cause
),
HidError::HidApiErrorEmpty => write!(f, "hidapi error: (could not get error message)"),
HidError::FromWideCharError { wide_char } => {
write!(f, "failed converting {:#X} to rust char", wide_char)
}
HidError::InitializationError => {
write!(f, "Failed to initialize hidapi (maybe initialized before?)")
}
HidError::OpenHidDeviceError => write!(f, "Failed opening hid device"),
HidError::InvalidZeroSizeData => write!(f, "Invalid data: size can not be 0"),
HidError::IncompleteSendError { sent, all } => write!(
f,
"Failed to send all data: only sent {} out of {} bytes",
sent, all
),
HidError::SetBlockingModeError { mode } => {
write!(f, "Can not set blocking mode to '{}'", mode)
}
HidError::OpenHidDeviceWithDeviceInfoError { device_info } => {
write!(f, "Can not open hid device with: {:?}", device_info)
}
}
}
}
impl Error for HidError {
fn source(&self) -> Option<&(Error + 'static)> {
match self {
HidError::HidApiErrorEmptyWithCause { cause } => Some(cause.as_ref()),
_ => None,
}
}
}

@@ -38,5 +38,2 @@ // **************************************************************************

#[macro_use]
extern crate failure_derive;
extern crate failure;
extern crate libc;

@@ -47,3 +44,2 @@

use failure::Error;
use libc::{c_int, size_t, wchar_t};

@@ -70,6 +66,5 @@ use std::ffi::CStr;

if EXPECTED_CURRENT == HID_API_LOCK.compare_and_swap(EXPECTED_CURRENT,
true,
Ordering::SeqCst) {
if EXPECTED_CURRENT
== HID_API_LOCK.compare_and_swap(EXPECTED_CURRENT, true, Ordering::SeqCst)
{
// Initialize the HID and prevent other HIDs from being created

@@ -91,3 +86,5 @@ unsafe {

fn drop(&mut self) {
unsafe { ffi::hid_exit(); }
unsafe {
ffi::hid_exit();
}
HID_API_LOCK.store(false, Ordering::SeqCst);

@@ -323,5 +320,4 @@ }

wchar_to_string(ffi::hid_error(self._hid_device))
.map_err(|e| HidError::HidApiErrorEmptyWithCause {
cause: Error::from(e).compat(),
})?.ok_or(HidError::HidApiErrorEmpty)?
.map_err(|e| HidError::HidApiErrorEmptyWithCause { cause: Box::new(e) })?
.ok_or(HidError::HidApiErrorEmpty)?
},

@@ -328,0 +324,0 @@ })

Sorry, the diff of this file is not supported yet