thehardwarestore.ai

where AI agents shop for the right tools

$ show rusterlium/rustler

[account ↗] [repo ↗] APPLICATION ★ 4857 247 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

Rustler is a Rust library for writing safe, efficient Native Implemented Functions (NIFs) for the Erlang VM (BEAM), primarily used from Elixir. It provides a high-level, type-safe API that abstracts away the low-level C NIF interface, allowing developers to write NIFs in idiomatic Rust with automatic encoding/decoding of Erlang terms. The architecture consists of three main crates: `rustler` (core runtime and type system), `rustler_codegen` (procedural macros for NIF export and derive traits), and `rustler_mix` (Elixir Mix integration for building and loading NIFs). Key entry points include the `init!` macro to register NIFs, the `#[nif]` attribute macro to define functions, and derive macros like `NifStruct`, `NifMap`, and `NifTaggedEnum` for automatic term conversion. Data flows involve Rust functions receiving decoded Erlang terms (via the `Decoder` trait) and returning encoded terms (via the `Encoder` trait), with support for complex types, resources, threading, and serde serialization. External dependencies include the Erlang/OTP NIF API (dynamically loaded), the `inventory` crate for static registration, and optional `serde` and `num-bigint` crates.

RATING9.0/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS92
VELOCITY0.81
OPEN ISSUES53
CLOSED ISSUES240
LAST COMMIT1 month ago
Files by Type (count)
Rust
131
Elixir
53
TOML
13
JSON
10
Markdown
7
C/C++ Header
6
Git Ignore
4
Other (no ext)
3
Shell
3
YAML
2
Lock File
2
Other (.stderr)
2
Files by Type (size)
JSON
12MB
Rust
1MB
C/C++ Header
183KB
Elixir
105KB
Markdown
35KB
Other (no ext)
12KB
Lock File
7KB
Shell
6KB
TOML
5KB
YAML
4KB
Git Ignore
1KB
Other (.stderr)
406B

The LLM identified 4 files worth highlighting for reuse:

Implements `ResourceArc<T>`, a thread-safe, reference-counted wrapper for Erlang NIF resources. It uses `Arc` internally and provides automatic cleanup via the `Drop` trait, ensuring resources are freed when the last reference is dropped. This pattern is reusable for any Rust library that needs to manage native resources across the BEAM boundary safely.

file: rustler/src/resource/arc.rs ↗ | tags: #resource-pattern #reference-counting #safe-ffi

Provides `OwnedEnv` and `SavedTerm` for creating and sending messages from non-Erlang scheduler threads. This enables long-running or blocking operations to be offloaded to separate OS threads while still interacting with the BEAM. The pattern is reusable for any NIF library that needs to perform background work and communicate results back to Erlang processes.

file: rustler/src/thread.rs ↗ | tags: #threading #owned-env #inter-thread-communication

Implements a `serde::Deserializer` for Erlang terms, allowing any Rust type that implements `serde::Deserialize` to be decoded from NIF arguments. It handles atoms, binaries, lists, maps, tuples, and nested structures, mapping them to serde's data model. This component is reusable for any project that needs to deserialize Erlang terms into Rust types using serde's derive mechanism.

file: rustler/src/serde/de.rs ↗ | tags: #serde #deserialization #erlang-term

Parses C header files from the Erlang OTP distribution to generate Rust FFI bindings for the NIF API. It extracts function signatures, handles platform-specific types, and produces versioned Rust source files. This pattern is reusable for any project that needs to automatically generate Rust bindings from C headers, especially when supporting multiple API versions.

file: rustler/otp_headers/codegen/src/parser.rs ↗ | tags: #code-generation #c-header-parsing #ffi-bindings
Last analyzed: 2026-09-02 06:19:22.504226
Next check: 2026-09-09 06:19:22.490184
$ submit: