windows-rs README

The project's README from github.com/microsoft/windows-rs. As one markdown file: README.md.

windows-rs provides Rust crates for Windows APIs, from COM support and system services to UI and raw bindings.

Prefer the focused crates below when they cover the functionality you need. For additional APIs, windows-bindgen can generate a minimal project-specific binding, while windows and windows-sys provide broad API coverage behind feature flags for binary applications.

Reusable libraries should avoid the windows and windows-sys umbrella crates. They add dependency weight and version churn, and several libraries can bring incompatible versions of the same large crate into one dependency tree. Prefer the focused crates for shared Windows types and generate any remaining private bindings with windows-bindgen.

Each crate page covers usage and maintenance. Generated API documentation is available on docs.rs.

Crates

Core types and interop

Crate Description
windows-core COM and WinRT types, traits, and authoring macros.
windows-result Windows error handling and propagation.
windows-strings Windows string types, conversions, and macros.
windows-link Links C-style functions without import libraries.

Values and collections

Crate Description
windows-collections WinRT collections.
windows-numerics Graphics vectors and matrices.
windows-reference Implementation of WinRT IReference<T>.
windows-time WinRT DateTime and TimeSpan types.

Async and threading

Crate Description
windows-future WinRT asynchronous operations as Rust futures.
windows-threading Safe wrapper over the Win32 thread pool.

System services

Crate Description
windows-registry Safe Windows registry access.
windows-services Support for authoring Windows services.
windows-version Queries the Windows version at runtime.

UI and graphics

Crate Description
windows-reactor Declarative UI library backed by WinUI 3.
windows-canvas 2D graphics built on Direct2D.
windows-composition Windows composition visuals.
windows-webview Safe wrapper around the WebView2 browser control.
windows-window Window creation and message dispatch.
windows-pickers Windows file and folder pickers.
windows-animation Wrapper around the Windows Animation Manager.
windows-reactor-setup Stages the Windows App Runtime.

Code generation and metadata

Crate Description
windows-clang Generates RDL from C and C++ headers using libclang.
windows-default Embedded Windows metadata for build tools.
windows-metadata Reads and writes ECMA-335 metadata.
windows-rdl Parses RDL and generates ECMA-335 metadata.
cppwinrt Packages the C++/WinRT compiler.

Macro implementation

These crates implement macros exported by windows-core. Applications should use the windows-core exports rather than depend on them directly.

Crate Description
windows-implement Implements the #[implement] macro.
windows-interface Implements the #[interface] macro.

Windows API bindings

Use windows-bindgen when the focused crates above do not cover the APIs you need. Binary applications may instead prefer the convenience of the pre-generated windows or windows-sys umbrella crate.

Crate Description
windows-bindgen Generates Rust bindings from Windows metadata.
windows Typed bindings for C-style, COM, and WinRT APIs.
windows-sys Raw bindings for C-style Windows APIs.

windows-rs (microsoft/windows-rs)

Searching Database…

Что это такое?windows-rs — официальный набор крейтов Microsoft для Rust, который открывает доступ к API Windows: от поддержки COM и WinRT до системных служб и интерфейса. С его помощью программы на Rust могут обращаться к платформе Windows.
Это одна библиотека или целый набор крейтов?Это воркспейс из множества узкоспециализированных крейтов (windows-core, windows-registry, windows-webview и других) и двух зонтичных крейтов, windows и windows-sys, которые объединяют широкий набор API и управляются через feature-флаги.
Как мне добавить это в проект?Добавьте в зависимости Cargo нужный узкий крейт или зонтичный крейт windows/windows-sys (последний удобен для готовых приложений). Сгенерированная документация API для каждого крейта доступна на docs.rs.
Нужно ли мне генерировать собственные привязки для недостающих API?Да, если узкий крейт не покрывает нужный API, используйте windows-bindgen, чтобы сгенерировать минимальные привязки для вашего проекта на основе метаданных Windows.
Почему библиотекам не стоит просто зависеть от крейтов windows или windows-sys?Библиотекам стоит избегать зонтичных крейтов, так как они добавляют вес зависимостей и частые изменения версий, а разные библиотеки, подтягивающие несовместимые версии одного и того же большого крейта, могут конфликтовать в одном дереве зависимостей.
Кому стоит использовать узкие крейты, а кому зонтичные?Авторам библиотек лучше использовать узкие крейты для общих типов Windows и при необходимости генерировать приватные привязки; готовым приложениям удобно пользоваться зонтичными крейтами windows или windows-sys.
Это работает только в Windows?Да, эти крейты оборачивают нативные API Windows (COM, WinRT, Win32), поэтому они рассчитаны именно на платформу Windows.
Что такое windows-reactor?Это декларативная библиотека для интерфейсов на основе WinUI 3, входящая в группу крейтов для интерфейса и графики.
Могу ли я с этим создавать нативные приложения с интерфейсом?Да, такие крейты, как windows-reactor, windows-canvas, windows-composition, windows-webview и windows-window, покрывают декларативный интерфейс, 2D-графику через Direct2D, визуальные элементы композиции, встроенный браузерный элемент WebView2, а также создание окон и диспетчеризацию сообщений.
Есть ли поддержка прямого вызова заголовочных файлов C/C++?Да, windows-clang с помощью libclang генерирует метаданные RDL из заголовочных файлов C и C++, которые затем можно преобразовать в привязки.
What are similar projects?FreeRDP, iced, openai-python, RxJS, roslyn, pdfcraft, xi-editor, glfw
Creator
microsoft
Size
1.3 GB
Stars
12.8K
Age
7y
Commits · 90 Days