async only.Expand description
Executor-agnostic async stream wrappers for IOKit HID callback APIs.
Each function on an IOHIDManager, IOHIDDevice, or IOHIDQueue that
accepts a C callback is wrapped here as a
doom_fish_utils::stream::BoundedAsyncStream of typed events.
§Run-loop convention
Each stream subscription spawns a dedicated background thread that runs
a CFRunLoop. The IOKit source (manager / device / queue) is scheduled
on that thread’s run loop, so callbacks fire independently of any async
executor or the caller’s run loop. When the stream handle is dropped the
run loop is stopped, the thread is joined, and all IOKit resources are
released in the background thread before drop returns.
§Stream surfaces
| Stream type | IOKit registration | Event payload |
|---|---|---|
ManagerInputValueStream | IOHIDManagerRegisterInputValueCallback | InputValueEvent |
ManagerDeviceMatchingStream | IOHIDManagerRegisterDeviceMatchingCallback | DeviceMatchingEvent |
ManagerDeviceRemovalStream | IOHIDManagerRegisterDeviceRemovalCallback | DeviceRemovalEvent |
ManagerInputReportStream | IOHIDManagerRegisterInputReportCallback | InputReportEvent |
DeviceRemovalStream | IOHIDDeviceRegisterRemovalCallback | () |
DeviceInputValueStream | IOHIDDeviceRegisterInputValueCallback | HidValue |
QueueValueStream | IOHIDQueueRegisterValueAvailableCallback | () |
§Prerequisites for manager-level streams
Before calling ManagerInputValueStream::subscribe,
ManagerDeviceMatchingStream::subscribe,
ManagerDeviceRemovalStream::subscribe, or
ManagerInputReportStream::subscribe you must call
crate::HidManager::set_device_matching (or its _dict / _multiple
variants) on the manager. Scheduling an IOHIDManager on a CFRunLoop
without a device-matching filter causes IOKit to raise SIGTRAP; passing
None matches all devices.
use iohidmanager::prelude::*;
use iohidmanager::async_api::ManagerDeviceMatchingStream;
let manager = HidManager::new().unwrap();
manager.set_device_matching(None).unwrap(); // required before any subscribe call
let stream = ManagerDeviceMatchingStream::subscribe(&manager, 32);Structs§
- Device
Input Value Stream - Async stream of
HidValueevents fromIOHIDDeviceRegisterInputValueCallback. - Device
Matching Event - Event emitted by
ManagerDeviceMatchingStream. - Device
Removal Event - Event emitted by
ManagerDeviceRemovalStream. - Device
Removal Stream - Async stream of
()events fromIOHIDDeviceRegisterRemovalCallback. - Input
Report Event - Event emitted by
ManagerInputReportStream. - Input
Value Event - Event emitted by
ManagerInputValueStreamandDeviceInputValueStream. - Manager
Device Matching Stream - Async stream of
DeviceMatchingEvents fromIOHIDManagerRegisterDeviceMatchingCallback. - Manager
Device Removal Stream - Async stream of
DeviceRemovalEvents fromIOHIDManagerRegisterDeviceRemovalCallback. - Manager
Input Report Stream - Async stream of
InputReportEvents fromIOHIDManagerRegisterInputReportCallback. - Manager
Input Value Stream - Async stream of
InputValueEvents fromIOHIDManagerRegisterInputValueCallback. - Queue
Value Stream - Async stream of
()notifications fromIOHIDQueueRegisterValueAvailableCallback.