Skip to content

Generate Typed Erlang/Elixir/Gleam Definitions from Rust #628

Open
@SichangHe

Description

@SichangHe

So, what is preventing this?

It seems that we do have the source of truth from the Rust side. nif, NifStruct, and other Rustler macros have access to the typed raw arguments/fields; they just do not store that information in the Nif struct, yet. If we modify the macros to store those information, we would have them all in rustler::codegen_runtime::inventory::iter::<rustler::Nif>() when calling init!, right?

Code generation on the BEAM side would be more complicated, though. A few problems I can think of:

  • Where do we put the generated file?
  • Where to load the dylib from?
  • How to inject user configuration?
  • How to convert Rust types to BEAM types or TypeSpecs?
  • How to handle external types?

In #85, there seemed to be interest from @tsloughter and @lpil, but the rebar3_run and rebar3_cargo mentioned there seem to have staled. I guess it would be much better to just integrate most of the code generation into Rustler itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions