Microsoft has announced Rust/WinRT project that provides a natural and idiomatic way for Rust developers to call Windows APIs. Rust/WinRT lets you call any WinRT API past, present, and future using code generated on the fly directly from the metadata describing the API and right into your Rust package where you can call them as if they were just another Rust module.
The Windows Runtime is based on Component Object Model (COM) APIs under the hood and is designed to be accessed through language projections like C++/WinRT and Rust/WinRT. Those language projections take the metadata describing various APIs and provide natural bindings for the target programming language. This allows developers to more easily build apps and components for Windows using their desired language. You can then use those Windows APIs to build desktop apps, store apps, a component, NT service, or device driver.
Here below is a simple example of Rust calling a Windows API.
use windows::data::xml::dom::*; let doc = XmlDocument::new()?; doc.load_xml("<html>hello world</html>")?; let root = doc.document_element()?; assert!(root.node_name()? == "html"); assert!(root.inner_text()? == "hello world");
For more meaningful example, you can check out the following Minesweeper game implemented using Rust/WinRT: https://github.com/robmikh/minesweeper-rs
Microsoft noted that this is a very early public preview, so more features and fixes to come in the future. The home page of the project is on GitHub:
https://github.com/microsoft/winrt-rs
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options: