# hansihe/rustler

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/hansihe-rustler).**

4,806 stars · 243 forks · Rust · Apache-2.0

## Links

- GitHub: https://github.com/hansihe/Rustler
- Homepage: https://docs.rs/crate/rustler
- awesome-repositories: https://awesome-repositories.com/repository/hansihe-rustler.md

## Description

Rustler is a toolkit and interface for building safe, high-performance native extensions that integrate Rust code with the BEAM virtual machine. It provides a bridge for writing native functions in Rust that integrate with Erlang and Elixir.

The project focuses on preventing virtual machine crashes by catching Rust panics during the execution of native functions. It utilizes a safe interface to encapsulate raw pointers and provide type-safe abstractions for native extensions.

The toolkit covers cross-language data marshalling through trait-based term conversion and manages the lifecycle of memory objects via reference-counted resource management. These capabilities allow for the replacement of interpreted code with compiled Rust functions to improve execution speed.

## Tags

### Programming Languages & Runtimes

- [Erlang NIF Development](https://awesome-repositories.com/f/programming-languages-runtimes/erlang-nif-development.md) — Provides a comprehensive toolkit for writing high-performance native functions (NIFs) in Rust for Erlang and Elixir.
- [BEAM NIF Bridges](https://awesome-repositories.com/f/programming-languages-runtimes/c-language-bridges/rust-bridges/beam-nif-bridges.md) — Acts as a bridge for writing native functions in Rust that integrate with the Erlang virtual machine and Elixir.
- [Safe Panic Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/native-call-synchronization/managed-to-native-function-calls/safe-panic-wrappers.md) — Implements automatic panic catching in Rust native functions to prevent the BEAM virtual machine from crashing. ([source](https://github.com/hansihe/rustler#readme))
- [Rust Native Extensions](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-native-addons/rust-native-extensions.md) — Ships a toolkit for implementing high-performance Rust native extensions that safely handle data terms.
- [Safe VM Interfaces](https://awesome-repositories.com/f/programming-languages-runtimes/node-js-native-addons/rust-native-extensions/safe-vm-interfaces.md) — Provides a safe interface that prevents BEAM virtual machine crashes by catching Rust panics.
- [Rust-Erlang Integration](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/functional-languages/rust-erlang-integration.md) — Connects Rust code with Erlang systems to leverage memory safety and speed while maintaining stability.
- [Rust Native Extensions](https://awesome-repositories.com/f/programming-languages-runtimes/rust-native-extensions.md) — Provides a toolkit for building high-performance native extensions in Rust for the BEAM virtual machine. ([source](https://github.com/hansihe/rustler#readme))
- [C FFI Bridges](https://awesome-repositories.com/f/programming-languages-runtimes/c-language-bridges/rust-c-bridges/c-ffi-bridges.md) — Utilizes a C FFI bridge to map Rust functions to the Erlang VM native interface.
- [Cross-Language Data Exchange](https://awesome-repositories.com/f/programming-languages-runtimes/cross-language-data-exchange.md) — Facilitates the bidirectional movement of data between the Rust native layer and the Erlang runtime.
- [Safe Pointer Abstractions](https://awesome-repositories.com/f/programming-languages-runtimes/safe-pointer-type-conversions/safe-pointer-abstractions.md) — Encapsulates unsafe raw pointers into a type-safe Rust API to prevent memory corruption bugs.

### Data & Databases

- [Trait-Based Term Conversions](https://awesome-repositories.com/f/data-databases/data-encoding/erlang-term-format-encoding/trait-based-term-conversions.md) — Uses generic traits to encode and decode data between Rust types and Erlang terms.

### Development Tools & Productivity

- [Runtime Crash Prevention](https://awesome-repositories.com/f/development-tools-productivity/behavior-configuration/panic-handlers/runtime-crash-prevention.md) — Wraps Rust code in panic handlers to prevent internal language errors from crashing the host virtual machine.

### Operating Systems & Systems Programming

- [Reference Counting](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/automated-reclamation-systems/reference-counting.md) — Implements reference counting to track Rust memory objects and trigger cleanup via the BEAM garbage collector.
- [Cross-Runtime Resource Management](https://awesome-repositories.com/f/operating-systems-systems-programming/low-level-memory-io/cross-runtime-resource-management.md) — Manages Rust memory structures that can be safely passed to and released by the Erlang garbage collector.

### Software Engineering & Architecture

- [Memory Lifecycle Management](https://awesome-repositories.com/f/software-engineering-architecture/block-based-data-models/data-block-memory-management/contiguous-memory-buffers/manual-pointer-management/pointer-memory-management/object-reference-resolution/memory-lifecycle-management.md) — Implements a mechanism for passing memory structure references to external code and automatically releasing them via the GC. ([source](https://github.com/hansihe/rustler#readme))
- [Native Module Optimizations](https://awesome-repositories.com/f/software-engineering-architecture/native-module-optimizations.md) — Enables replacing slow interpreted BEAM code with compiled Rust functions to improve execution speed.

### Part of an Awesome List

- [Native Implemented Functions](https://awesome-repositories.com/f/awesome-lists/devtools/native-implemented-functions.md) — Safe NIF development using the Rust language.
