4 releases (2 breaking)
0.3.1 | Nov 15, 2023 |
---|---|
0.3.0 | Nov 15, 2023 |
0.2.0 | Nov 22, 2021 |
0.1.0 | Nov 9, 2021 |
#55 in #net
81KB
2K
SLoC
rnet
Easily call into Rust from C# or other .net langauges.
Usage
- Add
rnet::root!();
to your crate. - Use
#[derive(Net)]
on any structs to be shared with .net. - Apply the
#[net]
attribute to any standalone functions which should be callable from .net. - Build your rust project as a
cdylib
. - Generate C# bindings for your project:
cargo install rnet-gen rnet-gen "<path to .dll/.so/.dylib>" > "<path to generated file.cs>"
- Include the C# file in your .net project.
- Add a link to the compiled rust library to your .net project, and set it to "Copy if newer".
- Optional: Configure the above steps to run automatically as pre-build steps.
For languages other than C#, you'll need to build the exported C# file into its own class library, and then add a reference to that from a project of any .net language.
Dependencies
~4.5MB
~77K SLoC