Skip to content

HenryQuan/dart-c-rust

Repository files navigation

Dart-C-Rust

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.

Code generation

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.

ffigen

This library generates the dart bindings from the C header generated by cbindgen.

  • Setup LLVM
  • Install all packages
  • Run with dart run ffigen

cbindgen

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

About

Use Rust pointers in C or Dart

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published