Rustler is a library for writing Erlang NIFs in safe Rust code.
Rustler solves the problem of integrating performance-critical Rust code into Erlang and Elixir applications while maintaining the stability of the BEAM virtual machine. The library prevents crashes by catching Rust panics before they unwind into C and provides automatic handling of encoding and decoding between Rust values and Erlang terms. It eliminates boilerplate through attribute macros that make Rust structs automatically encodable and decodable, and supports resource objects that allow safe passing of Rust struct references into Erlang code with automatic cleanup.
Rustler is most suitable for Elixir and Erlang projects that need to call computationally intensive Rust functions. The project currently favors Elixir over pure Erlang. Adoption is straightforward through the rustler Elixir library, which provides a mix task to generate new NIFs. If you are already using serde for serialization, the project supports a serde feature that integrates with existing serde-based workflows. The library maintains compatibility with the three newest major OTP versions and three newest minor Elixir versions, with configurable NIF version support through Cargo features to match your deployment environment.
The project maintains active community engagement through Matrix and Slack channels. Development follows a structured approach to version support, explicitly defining minimal supported Rust versions and NIF versions through documented configuration. The codebase is organized to support both Erlang and Elixir ecosystems, with clear documentation and getting-started guides provided through the official Elixir package.