winsafe wraps a hand picked slice of Win32 in safe Rust with a GUI layer on top
Windows API and GUI in safe, idiomatic Rust.
At a glance
- What is it?
- rodrigocfd/winsafe is an MIT licensed crate that exposes low-level Win32 constants, functions and structs plus a set of high-level structs for building native Windows GUI applications, with the whole surface split into Cargo features so only what you use gets compiled. The author states plainly that it does not cover all of Win32 and points at the unsafe bindings crates for that, and machine generated pull requests are not accepted.
- Who is it for?
- Adopt winsafe if you are writing a native Windows application in Rust and want memory-safe calls into the Win32 API plus a GUI layer that saves you from the raw message loop, since the high-level window and control abstractions are the reason to choose this crate over a generic binding generator. Do not adopt it expecting complete Win32 coverage, because the README says so itself and points to the unsafe winapi and windows crates for that.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 11 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
A hand maintained safe slice of a very large API
WinSafe is described as Windows API and GUI in safe, idiomatic Rust, and the important word in the repository description is handwritten: it has been handwritten since 2019, and the README adds that LLM-generated pull requests are not welcome. That single line tells you the maintenance model. This is a curated binding set that a person keeps in step with the platform, not a generated one that follows a metadata file. The crate has two layers. The low-level layer gives you Win32 API constants, functions and structs, and the high-level layer gives you structs for building native Win32 GUI applications, where the high-level GUI abstractions live behind their own Cargo feature. For a Rust developer whose program has to talk to Windows properly, that is the pitch: the safety of the language applied to an API surface that is otherwise all pointers and handles.
The coverage table, and the honest caveat under it
The README publishes a table of how much of the platform is implemented, and the numbers are large. 924 functions, 266 structs, 12,330 constants, 684 window messages, 55 handles, 99 COM interfaces and 645 COM methods, with a badge putting the project at 70.3 thousand lines of code. Underneath that table sits the caveat that matters most for a decision. The README says that although WinSafe already has a lot of Win32 APIs, it does not have everything, simply because the Win32 API is gigantic, and then it points readers who want comprehensive coverage at the winapi and windows crates, noting that those are unsafe but have everything. That is an unusually clear statement of the trade. You choose this crate for the safety and the GUI layer and accept that a specific API you need might be missing, or you choose a generated binding and write the unsafe code yourself.
Cargo features are the compile-time switch
The APIs are split into Cargo features, named mostly after the native Windows DLLs and libraries they cover, and the stated reason is to speed up compilation time, since only the features you include will be compiled. The list runs from advapi for Advapi32.dll and Ktmw32.dll, through comctl for the Common Controls, dshow for DirectShow, dwm for the Desktop Window Manager, dxgi, gdi for Windows GDI, htmlhelp, kernel for Kernel32.dll, mf for Media Foundation, ole and oleaut for OLE and OLE Automation, psapi for the Process Status API, shell for the COM-based Windows Shell, taskschd for the Task Scheduler, user for User32.dll and ComDlg32.dll, uxtheme for extended window theming, version for manipulating executable version information, wininet, winmm, winspool for the Print Spooler API and winusb. The gui feature pulls in comctl and uxtheme, and there is a separate raw-dylib feature that enables raw-dylib linking. The dependency graph is published as a chart in the repository, and the README notes that you do not need to think about transitive feature resolution, since Cargo handles that once you use a feature.
Windows come in two flavours, programmatic or from a resource file
WinSafe lets you create windows in two ways. You can define the parameters programmatically, or you can load dialogs from a .res file created with a WYSIWYG resource editor, which is the route for anyone who has laid out a dialog visually. The programmatic path is the interesting one, because the shape of the API is what makes the crate pleasant to use. A window is a struct that owns the window manager, and a control holds a reference to its parent:
#[derive(Clone)]
pub struct MyWindow {
wnd: gui::WindowMain, // responsible for managing the window
btn_hello: gui::Button, // a button
}
impl MyWindow {
pub fn create_and_run() -> w::AnyResult<i32> {
let wnd = gui::WindowMain::new(
// instantiate the window manager
gui::WindowMainOpts {
title: "My window title",
size: gui::dpi(300, 150),
..Default::default() // leave all other options as default
},
);The options struct takes a title and a size expressed with a dpi helper that scales the values, and the rest of the fields are filled from a default, so you only state what differs. The dependency block for a project using the GUI layer enables the gui feature:
[dependencies]
winsafe = { version = "0.0.29", features = ["gui"] }The high level layer covers the controls a desktop app actually uses
The GUI abstractions cover two groups. The first is user custom windows and dialogs in five flavours: main, modal, modeless, control and message-only. The second is native controls, and the list is the one you would expect from a Windows application: button, check box, combo box, date and time picker, edit, header, label, list box, list view, month calendar, progress bar, radio button, status bar, tab, track bar, tree view and up down. The event handling is where the safety story shows, because the README's example notes how the click event is handled with a closure rather than a subclass procedure and a window procedure pointer, which is the part of raw Win32 where lifetimes and unsafe code usually leak in. If you are porting a dialog from a resource file, the controls you find in a .res are likely to be on that list, which is a good sign that the abstraction was designed around real dialogs.
Docs, examples and formatting rules live in separate places
The documentation is split by release channel, with the stable API on docs.rs and the nightly master branch published to the author's GitHub Pages site. Examples are not in this repository at all. They live in a dedicated repository, rodrigocfd/winsafe-examples, and the README links to specific folders in it, such as the button click example and the dialog resources example. The top level of this repository shows the supporting files: a ch.sh script, a doc.sh script, a features-chart.md dependency graph, a rustfmt.toml and the src directory. The split is deliberate and follows the usual pattern for a library crate, where the published package is kept small. The Cargo manifest also sets include to a short list, the source, the manifest, the licence and the readme, so the published artifact carries the library and not the examples.
Pre-1.0 versioning on edition 2024
The manifest is small enough to read in full and tells you what kind of project this is. The package is winsafe at version 0.0.29, licensed MIT, categorised as api-bindings, gui and os::windows-apis, on edition 2024 with rust-version 1.87. The docs.rs metadata builds the documentation for the x86_64 Windows MSVC target by default, with aarch64 and i686 also listed, and with all features enabled so the published docs cover the whole surface. The repository has no GitHub releases, so the crates.io version is the release channel, and the last push was on 2026-10-12, days before the current date, so the work is current. A version number of 0.0.29 is worth understanding as a signal: the author has not committed to a stable API surface yet, and the README's own advice, that LLM-generated pull requests are not welcome, suggests changes are reviewed by hand.
Editorial conclusion
Adopt winsafe if you are writing a native Windows application in Rust and want memory-safe calls into the Win32 API plus a GUI layer that saves you from the raw message loop, since the high-level window and control abstractions are the reason to choose this crate over a generic binding generator. Do not adopt it expecting complete Win32 coverage, because the README says so itself and points to the unsafe winapi and windows crates for that. Before you start, decide which Cargo features you need, since the features are the compile-time switch and the dependency graph is published as a chart, and check the version, because the crate is still at 0.0.29 with a pre-1.0 version number.
Frequently asked questions
How do I add winsafe to a Rust project?
Add it to Cargo.toml as winsafe = { version = "0.0.29", features = [] } and then enable the Cargo features you want, since the APIs are split into features named after the native Windows DLLs they cover. Only the features you include are compiled, and Cargo resolves the transitive feature dependencies for you.
Does winsafe cover the whole Win32 API?
No. The README says so directly, because the Win32 API is gigantic, and points at the winapi and windows crates for comprehensive coverage, noting that those crates are unsafe. What winsafe implements is listed as 924 functions, 266 structs, 12,330 constants, 684 window messages, 55 handles, 99 COM interfaces and 645 COM methods.
What GUI controls does winsafe support?
User custom windows and dialogs come in main, modal, modeless, control and message-only flavours, and the native controls covered include button, check box, combo box, date and time picker, edit, header, label, list box, list view, month calendar, progress bar, radio button, status bar, tab, track bar, tree view and up down.
Where are the winsafe examples?
They are not in this repository. The README points to a dedicated examples repository at github.com/rodrigocfd/winsafe-examples, with individual folders for cases such as the button click example and loading dialogs from a .res resource file.
What licence is winsafe released under?
MIT, stated in the Cargo manifest and in the README badge, with the licence text in the LICENSE.md file at the repository root. The manifest also declares the package as private to the published file set, shipping only the source, the manifest, the licence and the readme.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/rodrigocfd-winsafe)Was this useful?