feat: handle device event in service handler #132
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have recently needed to receive device events as a windows service, and found out that I couldn't with the current version of windows-service. This PR is here to make this possible.
To receive those events, a call to
RegisterDeviceNotification
must be done. This is of course not done in this crate and let instead to the user.Then, instead of parsing the event data for every subtype of device events, I've chosen to keep the event data in raw form, and let the user of the crate do this parsing. This does not seem to be quite how the rest of the service event handler is written, but this is by far the simplest:
RegistryDeviceNotification
So all in all, it's imho much simpler and also efficient to let the user handle the conversion of this event data into rust. For example in my case, I only need to handle device arrival, and only some subset of those events.
Let me know what you think, or if you would prefer parsing those events to provide a nicer experience to the user. Also, thanks for your work on this crate :)
This change is