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:
The event data for device events can be quite complex (with first a HDR type, then different type of objects depending on the subtype stored in the header), and which type of events is received also depends on which parameters was provided to RegistryDeviceNotification
There are several type of device events (arrival, remove, custom, etc), and the user may only be interested in a subset of those
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 :)
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