This is an experiment on controlling a Rust raw pointer (e.g Hashmap) from C or Dart. The goal is to ask Rust to do some operations on the given pointer and return some data to another language using simple nested struct.
cbindgen
and ffigen
are used to generate the C header from Rust and Dart bindings from C. Run mingw32-make.exe header
to generate everything before running mingw32-make.exe all
.
This can be done manually as seen in hashmap.h
, but this won't be scalable in the long run. However, it is always good to experiment by writing the header and the binding manually first.
This library generates the dart bindings from the C header generated by cbindgen.
- Setup LLVM
- Install all packages
- Run with
dart run ffigen
This library generates C header from the Rust code.
- Install with
cargo install --force cbindgen
- Run with
cbindgen --config cbindgen.toml --crate pointer --output hashmap.h