Derive Macro rustler_codegen::NifException

source ·
#[derive(NifException)]
{
    // Attributes available to this derive:
    #[module]
    #[rustler]
}
Expand description

Derives implementations for the Encoder and Decoder traits which convert between an Elixir exception and a Rust struct.

For example, annotate the following struct:

#[derive(Debug, NifException)]
#[module = "AddException"]
pub struct AddException {
    message: String,
}

Write the corresponding Elixir exception definition:

defmodule AddException do
  defexception message: ""
end

Then the traits Encoder and Decoder are derived automatically for your Rust struct such that you can use the Elixir exception definition for it.