Replace winapi, com and widestring with the windows-rs crate:
What does it changes internally (should not be visible from the public API):
windows-rs comes with a BSTR module helper, so the wmi-rs one is no longer needed.
COM objects all properly implement Clone (with AddRef) and Drop (with Release), so no need to do it by hand, and no risk of memory issues when forgotten.
The implement feature gives access to easy COM implementation: a rust struct can implement a COM interface, and the interface comes in the form of a clean Rust trait.
The APIs are more rust-idiomatic to use: None can be passed for many optional parameters, and the return result is very often already a Result: the check_hres helper is no longer needed.
What does it changes externally (breaking changes):
The widestring dependency is no longer needed, and its errors are no longer exposed in the WMIError object. Instead, the BSTR helper from windows-rs is used, and this one generates the standard std::string::FromUtf16Error error. This gives less information on the conversion issue.
The BSTR helper from windows-rs also panics on allocation failure, making the WMIError::ConvertAllocateError obsolete. We could probably change this with an internal conversion if needed, but "panic on allocation failure" is probably baked in other windows-rs helpers...
Another point to take into account is that windows-rs is still getting updated regularly, and so it may be needed to release new wmi-rs versions more regularly to keep up with those updates. The windows-sys crate is a bit lower level and less often updated, and is supposed to be designed for libs like this. However, we need the COM helpers and the implement macro, which only exists in the higher-level windows crate.
Replace
winapi
,com
andwidestring
with thewindows-rs
crate:What does it changes internally (should not be visible from the public API):
windows-rs
comes with a BSTR module helper, so thewmi-rs
one is no longer needed.implement
feature gives access to easy COM implementation: a rust struct can implement a COM interface, and the interface comes in the form of a clean Rust trait.check_hres
helper is no longer needed.What does it changes externally (breaking changes):
widestring
dependency is no longer needed, and its errors are no longer exposed in the WMIError object. Instead, theBSTR
helper fromwindows-rs
is used, and this one generates the standardstd::string::FromUtf16Error
error. This gives less information on the conversion issue.BSTR
helper fromwindows-rs
also panics on allocation failure, making theWMIError::ConvertAllocateError
obsolete. We could probably change this with an internal conversion if needed, but "panic on allocation failure" is probably baked in other windows-rs helpers...Another point to take into account is that
windows-rs
is still getting updated regularly, and so it may be needed to release newwmi-rs
versions more regularly to keep up with those updates. Thewindows-sys
crate is a bit lower level and less often updated, and is supposed to be designed for libs like this. However, we need the COM helpers and the implement macro, which only exists in the higher-levelwindows
crate.Fixes #67