Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Rustishka
This project offers cool ways to interact between these super safe & supe fast languages!
Rust <===> C# interop at the highest level!
This effect is created by using special libraries on the C# side and on the Rust side.
Overview
C# Side
The library provides a mini interface for the Rust library to interact with the DotNet environment.
private struct BridgeConvention
{
public delegate* <object, Type> FGetType;
public delegate* <string, bool, Type> FSearchType;
public delegate* <Type, int, void*> FGetMethodAtSlot;
public delegate* <Type, object> FAlloc;
public delegate* <byte*, int, string> FAllocString;
public delegate* <Type, int, Array> FAllocArray;
public delegate* <delegate*<void>, Exception> FTryCatch;
public delegate* <Exception, void> FThrow;
}
The developer must connect the library to the interface using a function call:
RustishkaBridge.Bridge.ConnectRustModule(string libPath, out IntPtr moduleHandle) // to load lib and connect
// or
RustishkaBridge.Bridge.ConnectRustModule(IntPtr moduleHandle) // connect without loading. Use if the module has already been loaded before.
Rust side
The developer provides an export function with this signature. It will be called in ConnectRustModule
initialize_rustishka!;
Important thing
Structures with class content for Rust have to be created manually.
You can use Sharplab as well.
Features
- Rust lib can search for a type in the DotNet runtime:
let integer_type = search_type_cached;
- Rust lib can allocate objects & arrays:
let someType = search_type_cached;
let obj: *mut = allocate; // alloc without constructor invoke !!!
- Rust lib can call virtual functions:
let someType: *mut = ...;
let baseType = someType.get_base_type;
This is presented in the form of pseudo wrappers:
define_virtual!;
where: 11 - row eq slotId / 8
, 4 - index eq slotId % 8
- Rust lib can call non-virtual instance and static functions.
someObject.some_instance_method;
some_static_method
let val: *mut = new;
where
- Rust lib can access to static fields
;
// where
define_typeof!;
get_cool_static_field
- Rust lib can use typeof sugar
define_typeof!;
// in method
let ty : *mut = type_of;
- Rust lib can easily alloc managed arrays
managed_array!;
// ex:
managed_array!;
managed_array!;
- Rust lib can use almost all of .NET Reflection's features! (Even use DynamicMethod!)
As you can see: it`s very human design, very easy to use.
Examples
TODO
- Add support for field access
- .Net type inheritance in Rust by creating a custom type via .Net TypeBuilder & overriding methodtable entries.
- Source generators (atm it's scary Rustishka.Tools)