Skip to content

Commit

Permalink
refactor(windows_api): use handle trait from 0.20
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Sep 21, 2021
1 parent 63cf48d commit 2807caf
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 112 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
windows = "0.19"
windows = "0.20"

[build-dependencies]
windows = "0.19"
windows = "0.20"
3 changes: 3 additions & 0 deletions bindings/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
pub use windows::Handle;
pub use windows::Result;

::windows::include_bindings!();
Loading

0 comments on commit 2807caf

Please sign in to comment.