refactor(windows_api): use handle trait from 0.20

The 0.20.0 release of windows-rs includes a Handle trait which provides
ok() and invalid() fns for implementors, including HWND and HANDLE.

This is pretty cool (and also a big breaking change since the release
takes away is_null() at the same time...), so the code in windows_api.rs
has been updated to make use of this by implementing a
ProcessWindowsCrateResult trait with a process() fn.

When implemented for a windows::Result<T>, it will do any required
processing for T, and ensure that windows::Error is converted to an
eyre-compatible Report.

Switching to this means that I have been able to get rid of some of the
hacky error handling for weird behaviours encountered previously. So
far, they don't seem to be presenting again, but I will run with this
build for a couple of days to see if the false-negative errors are
really gone for good with this update.
This commit is contained in:
LGUG2Z
2021-09-20 18:21:40 -07:00
parent 63cf48daa5
commit 2807cafdd0
4 changed files with 96 additions and 112 deletions

View File

@@ -1 +1,4 @@
pub use windows::Handle;
pub use windows::Result;
::windows::include_bindings!();