Sample code for the blog post Calling Rust code from C#.
- Install Rust
- Install .NET SDK
- Install uniffi-bindgen-cs
- use version 0.2.0 to match the uniffi version we will use in the Rust code
cargo install uniffi-bindgen-cs --git https://github.com/NordSecurity/uniffi-bindgen-cs --tag v0.2.0
Build everything
build.sh
or first build the Rust library manually
cd rust-lib
cargo build
followed by building the C# host
cd csharp-host
dotnet build
Now you can invoke the C# host, which calls into the Rust library
cd csharp-host
dotnet run