-
Notifications
You must be signed in to change notification settings - Fork 238
Description
I'm currently using core-foundation-rs a couple of projects which have their own IOKit bindings to access USB HID and system power management state:
-
My USB HID bindings are based on Mozilla's authenticator-rs bindings, but I've fixed some issues with it, and made it use more
core-foundation-rsAPIs and add more Rust-like API surfaces (as the existing bindings were pretty bare-bones).Regarding licensing,
authenticator-rsis MPL-2.0 licensed; there would need to be a discussion with Mozilla folks about re-licensing for this project. My modifications are also MPL-2.0 licensed, but I'm happy for that to change to Apache-2.0/MIT like the rest of this project.The USB HID bindings would need some modifications to make it useful for things other than FIDO/CTAP authenticators, as they have hard-coded device matching rules, and
IOHIDManagerrequiresInput Monitoringpermission if you don't provide them.There are other macOS-compatible Rust bindings for USB HID, but they use the
hidapiC library, which has its own quirks and limitations. It seems likehidapi-rsis looking to move away fromhidapiand move to pure Rust bindings, and this would provide them a way to deliver it. -
My system power management API wrappers (
IORegisterForSystemPoweretc.) I've rolled myself, but these aren't in any public repository at present.I'm happy for this to be released as Apache-2.0/MIT as with the rest of this project, and that could be upstreamed fairly easily.
None of these implement 100% of IOKit APIs, but this can be an incremental process as with other parts of Core Foundation.
I think core-foundation-rs might be a good home for these bindings, as it hosts Rust bindings for a bunch of macOS platform APIs, and it seems to be the closest equivalent of "windows-rs but for macOS".
There's an existing io-kit-sys library (MIT licensed) which has a pending PR to switch to using core-foundation-sys, but this looks like it's no longer maintained. There are a bunch of forks of it which add more functionality (like power management), which at least show there's Rust community interest in having these sorts of APIs available.
My intent in raising this issue is to see if you're interested (as a project) in expanding in scope, before I start doing some further legwork (starting to upstream what I can, and starting discussions to unblock the rest).
My ultimate goal is to stop re-implementing IOKit APIs in multiple projects, and hopefully provide something useful to others in the process. 😄