Closed citreae535 closed 1 year ago
Hi,
Thanks for your efforts. However, your PR introduces a lot of changes, some of them are good, others are breaking or subject to discussion. It would be much simpler to review your changes if they were somehow isolated one from the other via separate PRs.
Close in favor of separate PRs
Bug fixes and refactors
1. Breaking: change
Service.delete
to borrow rather than consumeself
The underlying win32 API call merely marks the service for deletion. It can be called even if the service is not stopped and will not invalidate the caller's open handle to it. Making the function not consuming
self
allows the caller to decide when to close the handle. Docs and examples are updated to reflect this change.2. Refactor
double_nul_terminated
implementationfrom_vec
tofrom_slice
since it takes a slice, not aVec
.WideString
infrom_slice
with pre-calculated capacity.from_slice
.3. Bump
windows-sys
to0.45
An additional feature
Win32_Storage_FileSystem
is pulled in just for the flagFileSystem::DELETE
. This does not feel right, but hard-coding it ourselves feels worse.New Features
4. Add public method
Service.set_delayed_auto_start
This function configures if an auto-start service should be delayed.
5. Add public method
Error.is_os_error
This function checks if an error from win32 API call matches a specific OS error code.
Public API changes
These three are more opinionated public API changes based on my own needs, If these do not feel right for you, I'll revert them.
6. Breaking: remove
ServiceDependency
OsString
will suffice here since it is up to users to distinguish between service and group dependencies.OsString
starts with '+'.7. Breaking: change
ServiceInfo
to a borrowed typeThis change allows the caller to retain individual ownership of the fields of
ServiceInfo
without having to clone them.8. Possibly breaking: replace
err-derive
withthiserror
std::error::Error
for an enum with slightly different syntax. For this crate it is a drop-in replacement and unlikely to break anything.thiserror
has some extra features and are better maintained.thiserror
is vastly more popular (76,032,688 total downloads and 8400 dependent crates compared toerr-derive
's 2,175,409 and 71), it is very likely that many users of this crate already depend onthiserror
and will have less dependencies if this switch is made. (In fact, crates.io shows that this crate is the most downloaded dependent oferr-derive
)This change is