Microsoft has launched Rust/WinRT, a Rust-based Windows runtime project. The project, which is in line with the C?/WinRT, builds language projections for the Windows Runtime in standard languages and compilers, making it easier for Rust developers to call the Windows API and make it easier to build various Windows apps and components with Rust.
The Windows Runtime is based on the internal Component Object Model ,COM API and needs to be accessed through language projections such as C?/WinRT and Rust/WinRT. These language projections use metadata that describes various APIs and provide natural bindings to the target programming language. This allows developers to easily build applications and components for Windows in the language they need.
Rust/WinRT was proposed by Kenny Kerr, an engineer from the Windows team, last November and began trying. In a blog post at the time, he said that the Windows runtime had begun to increase support for various languages, but none of this could be separated from C? until Rust appeared.
Kerr believes that even though Rust’s learning curve may be daunting, it is likely to solve some of the most difficult issues in the relationship between C? and WinRT. “Imagine a C?/WinRT that doesn’t require an IDL: faster build times, and simple, integrated build systems. “
According to Microsoft, Rust/WinRT is able to call the WinRT API directly into the Rust package for any period of time, and developers can call them as if they were a Rust module.
Rust is very similar to C? in many ways, such as compiling and runtime models, but Rust is better at security, which is what Microsoft has always emphasized and valued.
The official introduction also gives some interesting examples of Rust/WinRT, such as this demo, a mine-clearing game that quickly ported from C?/WinRT to Rust/WinRT:
Rust/WinRT is still in early preview, and Microsoft hopes it will then provide more seamless interoperability with existing Win32 and COM APIs, including support for com-rs crate.
For more information, Microsoft’s official blog: https://blogs.windows.com/windowsdeveloper/2020/04/30/rust-winrt-public-preview/