Derive Macro rustler_codegen::NifStruct
source · #[derive(NifStruct)]
{
// Attributes available to this derive:
#[module]
#[rustler]
}
Expand description
Derives implementations for the Encoder
and Decoder
traits
which convert between an Elixir struct and a Rust struct.
For example, annotate the following Rust struct:
ⓘ
#[derive(Debug, NifStruct)]
#[module = "AddStruct"]
struct AddStruct {
lhs: i32,
rhs: i32,
}
Write the following corresponding Elixir struct definition:
defmodule AddStruct do
defstruct lhs: 0, rhs: 0
end
Then the traits Encoder
and Decoder
are derived automatically for your Rust struct
such that you can use the Elixir struct definition for it.