Crates.io | sf-rs |
lib.rs | sf-rs |
version | 0.2.1 |
source | src |
created_at | 2023-11-26 09:37:09.281962 |
updated_at | 2023-12-15 13:32:15.34139 |
description | A Rust library for interacting with the Service Fabric COM API on Windows. |
homepage | |
repository | https://github.com/avranju/sf-rs |
max_upload_size | |
id | 1048934 |
size | 11,104,256 |
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.
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.
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.