#[derive(NifTuple)]
{
// Attributes available to this derive:
#[rustler]
}
Expand description
Derives implementations for the Encoder
and Decoder
traits
which convert between a Rust struct and an Elixir tuple.
For example, annotate the following struct:
ⓘ
#[derive(NifTuple)]
struct AddTuple {
lhs: i32,
rhs: i32,
}
Create a value of that type:
ⓘ
let value = AddMap { lhs: 33, rhs: 21 };
Then the traits Encoder
and Decoder
are derived automatically for your Rust struct
such that encoding value
would result in an elixir
tuple with two elements like:
{33, 21}
And vice versa, decoding this map would result in value
.
The size of the tuple will depend on the number of elements in the struct.