- Make sure your projects
mix.exshas the:rustlercompiler listed in theprojectfunction:compilers: [:rustler] ++ Mix.compilers()If there already is a:compilerslist, you should append:rustlerto it. - Add your crate to the
rustler_cratesattribute in the `project function. See here. - Your NIF will now build along with your project.
defmodule Mjml do
use Rustler, otp_app: :mjml, crate: "mjml_nif"
# When your NIF is loaded, it will override this function.
def add(_a, _b), do: :erlang.nif_error(:nif_not_loaded)
endThis is a complete example of a NIF written in Rust.