Write a CPU-intensive function in Rust and call it from your Elixir app without risking a VM crash
Add a high-performance Rust NIF to an existing Elixir project in under an hour using the mix rustler.new generator
Pass complex Rust structs into Elixir with automatic type conversion using a single annotation on the struct
Integrate Serde serialization to share data between Rust and Elixir without manual data conversion code
Requires both a Rust toolchain and Elixir/OTP installed on the same machine.
Rustler is a library that lets developers write performance-critical code in Rust and call it from Erlang or Elixir programs. In Erlang's runtime, these are called NIFs, short for Native Implemented Functions. Writing NIFs directly in C is the traditional approach, but C code that crashes or behaves incorrectly can bring down the entire Erlang virtual machine with it. Rustler's main goal is to prevent that: code written through this library should not be able to crash the virtual machine, even if it encounters an unexpected error condition. The library handles the tedious parts of NIF development automatically. It generates the required boilerplate code, converts data between Erlang's internal format and Rust types, and intercepts Rust panics before they can propagate into C territory. Converting a Rust struct to something Erlang can understand takes a single annotation on the struct definition. Passing a reference to a Rust object into Erlang is also supported, with automatic cleanup when Erlang's garbage collector no longer holds a reference to it. Getting started in an Elixir project involves adding the Rustler package as a dependency and running a generator command that creates a skeleton NIF. The README shows a minimal example: a two-argument addition function in Rust becomes callable from Elixir with a few lines of code. Serde integration is available as an optional feature for projects that already use Rust's popular serialization library. Rustler supports the three most recent major OTP releases and the three most recent minor Elixir releases. It is dual-licensed under the MIT and Apache 2.0 licenses.
← rusterlium on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.