Crate rustler [−] [src]
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.
Getting Started
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.
Reexports
pub use types::NifEncoder; |
pub use types::NifDecoder; |
Modules
dynamic | |
env | |
resource |
A NIF resource allows you to safely store rust structs in a term, and therefore keep it across NIF calls. The struct will be automatically dropped when the BEAM GC decides that there are no more references to the resource. |
schedule | |
thread | |
types |
Macros
resource_struct_init | |
rustler_atoms |
Macro for defining Rust functions that return Erlang atoms.
To use this macro, you must also import the |
rustler_export_nifs |
Exports a given list of functions to a Erlang module. |
Structs
NifEnv |
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 |
NifTerm is used to represent all erlang terms. Terms are always lifetime limited by a NifEnv. |
Enums
NifError |
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. |
Type Definitions
NifResult |