n4r1b / ferrisetw

Basically a KrabsETW rip-off written in Rust
Other
65 stars 24 forks source link

Trait bound error caused by diff windows-rs dependence version #46

Closed 0xlane closed 2 years ago

0xlane commented 2 years ago

windows-rs version in ferrisetw's Cargo.toml is 0.39, but windows-rs version in my project is 0.42. This will cause the following error when compiling:

error[E0277]: the trait bound `Parser<'_>: TryParse<GUID>` is not satisfied
  --> src/main.rs:23:66
   |
23 |                     let guid: GUID = TryParse::<GUID>::try_parse(&mut parser, "Guid").unwrap();
   |                                      --------------------------- ^^^^^^^^^^^ the trait `TryParse<GUID>` is not implemented for `Parser<'_>`
   |                                      |
   |                                      required by a bound introduced by this call
   |
   = help: the following other types implement trait `TryParse<T>`:

My project can only be compiled by using windows-rs with the same version as ferrisetw.

Is there any good solution?

0xlane commented 2 years ago

I'm a rust beginner. This rust error has puzzled me for a long time. It took me a long time to know that it was caused by inconsistent dependence versions.

daladim commented 2 years ago

Hello, thanks for reporting.

Yes, using types from incompatible crate version results in errors that are sometimes hard to understand, as the compiler errors are not always very explicit.

In this case, instead of your version of GUID, your code should use our version of GUID, which is guaranteed to be the right version, e.g.

let guid: ferrisetw::GUID = TryParse::...

But...we forgot to re-export GUID it in ferrisetw, so that's currently impossible. The linked PR should resolve this issue. You can either use it as soon as now using an override in your cargo.toml, pointing the ferrisetw dep to https://github.com/daladim/ferrisetw/tree/re_exporting_windows_rs_types, or wait for us to publish the next minor release that will include this fix.

(also, note that we're working on the next major release as well, that you may want to have a look at: https://github.com/n4r1b/ferrisetw/tree/next_major_version)