sidit77 / async-hid

A async Rust library for interacting with HID devices
MIT License
3 stars 2 forks source link

Hashable DeviceId #4

Closed zardini123 closed 4 months ago

zardini123 commented 5 months ago

Implements Hash for DeviceId.

As mentioned in #3, all underlying platform-specific types used by DeviceId already implement Hash except windows-rs HSTRING. This PR utilizes the recent addition of HSTRING Hash impl to windows-rs (the windows-rs commit). Due to utilizing a more recent windows-rs version with API changes, additional changes were made to async-hid to satisfy those changes.

As of writing, the commit has been merged into windows-rs master (the PR, but a new release has not been released yet (will be version 0.56.0). Will update this PR when windows-rs releases a change.

Resolves #3

zardini123 commented 5 months ago

After attempting to include changes in a personal project, I found DeviceInfo::enumerate hangs indefinitely. From further analysis, the upgraded windows-rs crate these changes require (due to HSTRING hash contribution) result in some changes somewhere with the FindAllAsyncAqsFilter that hangs indefinitely. Going back to async-hid's original dependency version of windows-rs solves the problem.

https://github.com/sidit77/async-hid/blob/fc7a832ec965c2441b4a477bb6cd0d103ea898e7/src/backend/winrt/mod.rs#L33

Instead of spending the time to solve the reason of this indefinite hanging issue with windows-rs, I will instead implement a HashableHSTRING wrapper type as suggested by @sidit77 in https://github.com/sidit77/async-hid/issues/3#issuecomment-1985202469.

zardini123 commented 5 months ago

Manually tested, and found Hash implementation works. Changes are now ready for review.

zardini123 commented 5 months ago

Let me know if there is any changes that need to be done for this to be merged. Thanks!

sidit77 commented 5 months ago

I'm a bit busy right now without access to my PC but I'll try to review it as soon as I'm able.

zardini123 commented 5 months ago

No problem, thanks @sidit77!

sidit77 commented 4 months ago

Thanks for your contribution