Expand description
§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.
Macros§
- root
- Must be called by the
cdylib
crate.
Structs§
- Delegate0
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate1
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate2
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate3
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate4
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate5
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate6
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate7
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate8
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - Delegate9
- Rust type which can store and call a corresponding
Func<...>
orAction<...>
delegate from .net. - NetException
- This error type can be used to capture exceptions from
.net when calling a delegate with the appropriate
Result<T, NetException>
type.
Traits§
- FromNet
- Safety
- From
NetArg - Safety
- From
NetReturn - Safety
- Net
- Safety
- ToNet
- Safety
- ToNet
Arg - Safety
- ToNet
Return - Safety
Attribute Macros§
- net
- This attribute can be applied to a standalone function to allow it to be called from .net.
Derive Macros§
- Net
- This derive will implement the
Net
,ToNet
, andFromNet
traits for the given struct, allowing it to be passed to or returned from .net code.