ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
173 stars 82 forks source link

hiddevice: add `AsFd` impl #150

Closed JohannesSchilling closed 8 months ago

JohannesSchilling commented 8 months ago

This is useful to allow performing custom ioctls/operations on nonstandard HID devices.

ruabmbua commented 8 months ago

Its probably better to impl https://doc.rust-lang.org/std/os/fd/trait.AsFd.html ?

ruabmbua commented 8 months ago

Also, would you mind looking into if we can do the same for the rust windows backend?

JohannesSchilling commented 8 months ago

hm, on first look windows looks more difficult, because there we use https://docs.rs/windows-sys/latest/windows_sys/Win32/Foundation/type.HANDLE.html as basis, but the AsHandle trait uses https://doc.rust-lang.org/std/os/windows/io/type.RawHandle.html, so we'd have to cast isize to *mut c_void (?)

ruabmbua commented 8 months ago

I say lets ignore windows for now. I looked through some comments e.g. https://github.com/microsoft/windows-rs/issues/2222. If windows_sys devs decide to implement something, we can use that.

ruabmbua commented 8 months ago

Seems like your changes do not compile, pls check.

ruabmbua commented 8 months ago

Thx, will release a new version to crates.io soon.