Loading the NIF

The actual loading is done by calling use Rustler, otp_app: :my_app in the module you want to load the NIF in.
This sets up the @on_load module hook to load the NIF when the module is first
loaded.

defmodule MyProject.MyModule do
use Rustler, otp_app: :my_project, crate: :my_crate
# When loading a NIF module, dummy clauses for all NIF function are required.
# NIF dummies usually just error out when called when the NIF is not loaded, as that should never normally happen.
def my_native_function(_arg1, _arg2), do: exit(:nif_not_loaded)
end

Note that :crate is the name in the [lib] section of your Cargo.toml. The
:crate option is optional if your crate and otp_app use the same name.