[−][src]Derive Macro rustler::NifUnitEnum
#[derive(NifUnitEnum)] { // Attributes available to this derive: #[rustler] }
Implementation of the NifUnitEnum
macro that lets the user annotate an enum with a unit type
that will generate elixir atoms when encoded
ⓘThis example is not tested
#[derive(NifUnitEnum)] enum UnitEnum { FooBar, Baz, }
An example usage in elixir would look like the following.
test "unit enum transcoder" do
assert :foo_bar == RustlerTest.unit_enum_echo(:foo_bar)
assert :baz == RustlerTest.unit_enum_echo(:baz)
assert :invalid_variant == RustlerTest.unit_enum_echo(:somethingelse)
end
Note that the :invalid_variant
atom is returned if the user tries to encode something
that isn't in the Rust enum.