Documentation | Getting Started | Example
Rustler is a library for writing Erlang NIFs in safe Rust code. That means there should be no ways to crash the BEAM (Erlang VM). The library provides facilities for generating the boilerplate for interacting with the BEAM, handles encoding and decoding of Erlang terms, and catches rust panics before they unwind into C.
The library provides functionality for both Erlang and Elixir, however Elixir is favored as of now.
The easiest way of getting started, is using the Mix project generator.
mix archive.install https://github.com/hansihe/rustler_archives/raw/master/rustler_installer.ez
to install the tool.mix rustler.new <path>
and follow the instructions.This is the code for a minimal NIF that adds two numbers and returns the result. ```rust
extern crate rustler; use rustler::{ NifEnv, NifTerm, NifResult, NifEncoder };
rustlerexportnifs!( "Elixir.TestNifModule", [("add", 2, add)], None );
fn add<'a>(env: &'a NifEnv, args: &Vec