-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIL for Rust #308
Comments
Thanks Howard. While I agree that there's value to having something like WIL For Rust developers, I'm not sure that it belongs in a single Rust crate. It's more likely that a family of crates will provide useful wrappers for individual Win32 APIs. We may also find that some are unnecessary depending on what overlap exists in Rust's standard library and many such crates may already exist. On the other hand, perhaps we just need a neat collection of Windows-specific helpers in a single crate for systems programming on Windows. |
There are two crates that attempt to provide safe wrappers that I'm aware of: wio is published by Peter Atashian, maintainer of the winapi crate, and winapi-util by Andrew Gallant. Both authors are very capable, yet neither crate is anywhere near complete, nor do they show any significant signs of life. |
Closing as this is not specific to the Rust language projection. Feel free to keep the conversation going. |
@kennykerr Fair enough. I have no preference over the form. Just interested to see the relevant functionality also available to Rust developers. Is there a better venue for that discussion? |
I'll create a dedicated repo and link to it here. |
I was also looking for something like WIL for rust. The closest thing I found is https://github.com/rodrigocfd/winsafe. It's great, but it's a single-man effort for a huge scope, it'd be great to have Microsoft to maintain/invest in such a project. |
Many such helpers are now available including windows-core with rich COM support, windows-registry with safe and efficient registry access, windows-result with all kinds of error handling support, windows-strings that provides a bridge between Windows and Rust string types, windows-version with reliable version information, and more is on the way. There's also support for automatically freeing various handle types akin to WIL wrappers (#3013). |
@kennykerr thanks, that's good progress, keep it up! All of it looks really good, I just needed to do some registry operations and looked for a good wrapper. But it seems very simplistic, for example, in my use case I need to pass Also, like in WIL, it'd be great to be able to have a lib to take care of APIs which return variable-length strings: |
Feel free to create an issue, otherwise I'll forget. 😊 |
Created, thanks. Here's another example that I encountered recently: using
Note how the whole code is use winsafe::{self as w, prelude::*, co};
w::TaskDialogIndirect(&w::TASKDIALOGCONFIG {
common_buttons: co::TDCBF::OK,
window_title: Some("Title"),
content: Some("Content"),
callback: Some(Box::new(|hwnd: &w::HWND, tdn: w::Tdn| -> co::HRESULT {
match tdn {
w::Tdn::Created => println!("created"),
_ => {},
}
co::HRESULT::S_OK
})),
..Default::default()
})?; Safe, typed, beautiful, with a native lambda which can capture variables etc. Is something like this in scope for this repo? |
WIL is an invaluable library for Windows development using C++. Is there a Rust equivalent?
RAII helpers for Windows APIs like in win32_helpers.h, token_helpers.h and more would be welcome for Windows development using Rust. A 'WIL for Rust' moral equivalent or 'port to Rust language and idioms, to bring the same productivity gains to Rust as WIL brings to C++ development.
The text was updated successfully, but these errors were encountered: