3 unstable releases
0.2.1 | Dec 15, 2023 |
---|---|
0.2.0 | Dec 13, 2023 |
0.1.0 | Nov 26, 2023 |
#146 in Windows APIs
54 downloads per month
7MB
151K
SLoC
Contains (static library, 365KB) InternalFabricUUID.lib, (DOS exe, 240KB) .windows/winmd/sf.winmd, (static library, 165KB) FabricUUID.lib, (static library, 135KB) FabricUUID.lib, (static library, 195KB) InternalFabricUUID.lib, (static library, 5KB) FabricClient.lib and 3 more.
sf-rs
This crate contains Rust bindings for calling Service Fabric (SF) using the native COM API on Windows. The SF APIs are specified through IDL files that we fetch from the github.com/Azure/sf-c-util project.
Generating sf.winmd
The first step is to build the sf.winmd
file from the SF IDL files. We do this
using the win32metadata tooling
that knows how to munch IDL files and produce .winmd
files. An msbuild
project file has been crafted to accomplish this which you will find at
.metadata/generate.proj. I simply followed the
instructions from the blog post "Generating metadata for use with the windows
crate for
Rust"
to write this file up. Here's what you'll need to do to generate (or
re-generate) sf.winmd
:
-
If you haven't already, install the Visual Studio component called
MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)
using the Visual Studio Installer. If you're doing this out in the future when VS 2022 is old ancient software, please supplant 2022 with whatever is the current newfangled goodness. -
Open a Visual Studio Development terminal and navigate to the
.metadata
folder and run:
git submodule init --update
dotnet build
That's it. This will generate the sf.winmd
file in the .windows\winmd
folder.
Generating Rust bindings
Next we generate Rust bindings from the sf.winmd
file. This is accomplished
using the windows-bindgen and
windows-metadata crates. The code
for generating this lives in
crates/tools/api/src/main.rs. From a terminal
that's located in the root of the repo, run the following command to generate
(or re-generate) src/bindings.rs.
cargo run --package api
This will gobble up sf.winmd
and produce bindings.rs
which at the time of
writing this readme, is a measly 132,000 odd lines long. Easy peasy.
Dependencies
~130MB
~2M SLoC