Elixir rustler auto generate lib.ex

  1. When using GitHub - rusterlium/rustler: Safe Rust bridge for creating Erlang NIF functions , we already have to, in Rust land, tag the functions we want to export with #[rustler::nif]

  2. Then, on the elixir side, we have to create a lib/blah.ex which creates stubs for the functions Rust exports.

Question: is there some way to auto generate (2)? [The file w/ elixir stubs] There should be enough info in the Rust exports.

In theory - yes, but it would be impractical as often you do not want to expose NIFs as public functions, so you also need to implement glue code that will provide compatibility layer between BEAM code and NIF code.

1 Like

I am responding to you why there is no such functionality built-in. If you want, you can write code that will generate given module for you, that is why there is support for build.rs in Cargo.toml.

So yes, there is a way to do so if you want.

1 Like