Replace windows-sys with manual bindings#473
Replace windows-sys with manual bindings#473Jake-Shadle wants to merge 6 commits intonotify-rs:mainfrom
windows-sys with manual bindings#473Conversation
windows-sys with manual bindings
notify/src/windows.rs
Outdated
|
|
||
| #[allow(non_camel_case_types, non_snake_case)] | ||
| mod bindings { | ||
| pub const INFINITE: u32 = 4294967295; |
There was a problem hiding this comment.
my first reaction to this line was: this is why I wouldn't want to do the bindings myself, magic numbers from an OS for which I have no way of validating them, and if they're getting stale, it will take years till people notify (heh) that we're the ones getting it wrong
(but it's not a blocker by default)
There was a problem hiding this comment.
Yah, understandable, these bindings are sourced from the same https://github.com/microsoft/win32metadata that windows-sys uses if that's any consolation.
There was a problem hiding this comment.
Now think about the manual work you signed up for when we fix bugs in upstream win32metadata and push out fixes. (Minor in this crate, I admit, but work is work.)
|
I'm currently tending towards reverting #457 and simply going back to winapi. It may not be developed actively, but a) the (x86_64) winapi probably won't change until the heat death of the universe, b) we're not using anything special and c) that means winapi users converge towards one version. |
|
I think we would be fine with going to back to winapi for the moment, but I think as time moves forward most crates will either switch to windows-sys or use manual bindings to avoid the windows-sys churn, so I guess in the future it could be a situation where only a few crates are still using winapi, which shows they don't actually need to update to stay relevant, and IMO makes the manual binding approach more future proof. |
|
ok let's switch this around: if you want to have this, I'm willing to add a feature flag for this, let's call it |
|
That would work! Traveling tomorrow so might not have it for a bit. |
|
So unfortunately due to how features work I don't think that exact scenario works, but I've made |
notify/src/windows.rs
Outdated
| #[cfg(all(feature = "windows-sys", not(feature = "slim_windows")))] | ||
| use sys::*; | ||
|
|
||
| #[cfg(any(not(feature = "windows-sys"), feature = "slim_windows"))] |
There was a problem hiding this comment.
This is sadly a slippery slope. People use no-default-features to specify kqueue as macos backend. By this definition they automatically get the slim backend, which is unintentional (and got me wondering why the CI passed in the first place).
There was a problem hiding this comment.
I've already had a working change to make it a requirement, but then we'd have to bump the major version as everyone has to migrate their features. So that's not really a solution.
There was a problem hiding this comment.
I originally had it on just whether they had the slim feature enabled, but if they disable default features and don't enable slim it would fail to compile, but if you're OK with that I can do that instead.
|
We can just pin |
|
|
|
There is nothing wrong of having a crate installed multiple times. But there is a problem of having to write the bindings by yourself.
I strongly advise against pulling the bindings in the project code and taking the burden of maintaining the bindings by the project contributors. |
|
Ok I split out so that the internal bindings will only be used if the feature is enabled, and emit a compile error if neither the |
|
Ok, so this would still be a breaking change, thus requiring a v6 release. We would have to select windows-sys when none of these two features is specified? Because people followed this example, which doesn't specify that feature by default. |
|
Yes, it's a breaking change for those who use |
|
Hm, that's a fair trade I guess ? |
|
IMO yes, though there could be an issue if a crate depends on notify with |
|
There should be a simple process of updating the bindings, prior to merging this PR. |
What do you mean with that ? As it currently stands, this will be v6 |
|
On one hand it's not really a problem to do a v6 for this. But on the other side, doing a v6 only for a feature that, as of now, exactly one person uses is kind of weird. But I currently have no other breaking changes lined up. |
This assertion continues to be untrue, like I've mentioned before in other repositories. Is there a demonstrable problem here? Doesn't appear version churn was an issue for this crate. |
I take it you're referring to microsoft/windows-rs#1720 (comment)? If so...then you would need to update notify to point to different function/s regardless of where those bindings come from, and adding the additional binding(s) is a one time operation that can be done as needed. If you're saying that the constants/structs/ABI used by this crate can be changed at some point in the future by Microsoft, then I'm just honestly confused. To my knowledge Microsoft has never intentionally done an API/ABI breaking change like that in the history of Windows, which is why I can run a program (other than 16-bit) compiled 30 years ago for Windows 95 on a modern Windows machine without any issue.
It current version depends on 0.42 (6 months old), so it avoided the version churn by not updating, guaranteeing multiple versions since other crates have updated to new versions. |
So what, exactly? This isn't a problem in Rust ecosystem, as using multiple versions of the same library, when a major version is updated, is a Rust feature, not a bug. The approach you are proposing ( What real benefit do you want to bring by this change? |
|
Closing this since this thread is unproductive. Sorry for the headache @0xpr03 . |
This replaces the dependency on
windows-syswith manual bindings to the win32 functionality used by this crate.The rationale for this change is that these bindings will never meaningfully change so it doesn't make sense to use an external dependency, especially in light of microsoft/windows-rs#1720, which is why the currently published version of this crate actually ends up pulling in 2 version of windows-sys since the published version depends on 0.42, but the mio dependency uses 0.45. And as shown in #472, the minor version changes in windows-sys are noise, and only meaningful in the negative impact.