Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rustler

B2e91c9fedfd09fe60b98aa2621eef25?s=47 phonnz
March 03, 2021

 Rustler

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.

B2e91c9fedfd09fe60b98aa2621eef25?s=128

phonnz

March 03, 2021
Tweet

Transcript

  1. With Rust Extend elixir Rust MX

  2. None
  3. https://www.nasa.gov/

  4. None
  5. @phonnz Intuitivo

  6. None
  7. None
  8. https://redmonk.com/

  9. Agenda • Elixir • NIF • Rustler • Basics •

    Example
  10. Elixir • Functional language (10 years). • Erlang BEAM runtime.

    • Process order (M) • Macro system. • Let It Crash philosophy. • Concurrency. • Other languages best practices based.
  11. • C functions. • Transparent functions. • Shared Library. (SO,

    dll) • Runtime loadable. NIFs • Dynamically linked • Fastest way of calling C-code, Rust, Go.
  12. Rustler • Erlang NIFs • Safe Rust Code • No

    BEAM crash • Catches rust panics. • Supports Erlang as well • Decoding Rust Values • Encoding Rust values • Type composition • Safe reference passing.
  13. Elixir Dependecy {:rustler, "~> 0.21.1"}

  14. Compiler defp rustler_crates do [ rustex: [path: "native/rustex", mode: if(Mix.env()

    == :prod, do: :release, else: :debug)] ] end
  15. Elixir

  16. Rust

  17. Recursos https://github.com/rusterlium/rustler https://docs.rs/crate/rustler/0.21.1 https://www.youtube.com/watch?v=OvImHwddP44 https://speakerdeck.com/phonnz/rustmx-rustler

  18. @phonnz alfonso@intuitivo.ai Q&A