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.
This crate provides the entire runtime library for rustler. Code generators are located in the rustler_codegen library.
There is a
:rustler package on hex.pm that provides
functionality which makes working with Rustler easier, including project generators, an
automatic NIF compiler for Mix, and utilities for loading the compiled NIF.
For more information about this, see the documentation for rustler_mix.
Support for storing Rust data in Erlang terms.
Macro for defining Rust functions that return Erlang atoms.
To use this macro, you must also import the
Exports a given list of functions to a Erlang module.
On each NIF call, a NifEnv is passed in. The NifEnv is used for most operations that involve communicating with the BEAM, like decoding and encoding terms.
NifTerm is used to represent all erlang terms. Terms are always lifetime limited by a NifEnv.
Represents usual errors that can happen in a nif. This enables you to return an error from anywhere, even places where you don't have an NifEnv availible.