Safe Rust bridge for creating Erlang NIF functions

Overview

Rustler

Documentation | Getting Started | Example

Build Status

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.

Features:

  • Safety - The code you write in a Rust NIF should never be able to crash the BEAM.
  • Interop - Decoding and encoding rust values into Erlang terms is as easy as a function call.
  • Type composition - Making a Rust struct encodable and decodable to Erlang or Elixir can be done with a single attribute.
  • Resource objects - Enables you to safely pass a reference to a Rust struct into Erlang code. The struct will be automatically dropped when it's no longer referenced.

Getting started

The easiest way of getting started is the rustler elixir library.

  • Add the rustler elixir library as a dependency of your project.
  • Run mix rustler.new to generate a new NIF in your project. Follow the instructions.
  • If you're already using serde, consider using serde_rustler to easily encode and decode your data types into and from Elixir terms.

NOTE: If you have previously used Rustler, you need to run mix archive.uninstall rustler_installer.ez to remove it before generating the NIF.

What it looks like

This is the code for a minimal NIF that adds two numbers and returns the result.

#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
    a + b
}

rustler::init!("Elixir.Math", [add]);

Supported nif_version

Rustler uses erlang:system_info(nif_version) to detect the supported NIF version of the Erlang/OTP system for which the NIF is to be compiled. It is possible to restrict the NIF version to an older version if the NIF is to be compiled for an older version of Erlang. For example, if the target NIF version should be 2.7 (Erlang/OTP 17.3), this can be defined using an environment variable:

RUSTLER_NIF_VERSION=2.7 mix compile

Community

You can find us in #rustler on freenode or the elixir-lang slack.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • Unable to cargo build rustler

    Unable to cargo build rustler

    Hi, Rustler seems to be very promising but unfortunately I am not able to compile it.

    OS: Mac OS X siera Rust Version: 1.12.0.

    The error I am getting is:

    $ cargo build
        Updating registry `https://github.com/rust-lang/crates.io-index`
       Compiling easy-plugin-plugins v0.9.1
    error: no method named `pat_enum` found for type `&mut syntax::ext::base::ExtCtxt<'_>` in the current scope
       --> /Users/tomaskorcak/dev/microcrawler/gauc-elixir/native/gauc/target/debug/build/easy-plugin-plugins-64578d19b8e93d12/out/lib.rs:624:23
        |
    624 |     let pat = context.pat_enum(span, path, pats);
        |                       ^^^^^^^^
    /Users/tomaskorcak/.cargo/registry/src/github.com-1ecc6299db9ec823/easy-plugin-plugins-0.9.1/src/lib.rs:36:1: 36:47 note: in this expansion of include!
    
    error: aborting due to previous error
    
    error: Could not compile `easy-plugin-plugins`.
    
    To learn more, run the command again with --verbose.
    
    opened by korczis 26
  • Support more generalized macro for enum

    Support more generalized macro for enum

    Hi 👋

    While using Rustler, I've wanted to use more complex enum types for Elixir bindings. So I tried to implement it, which can be used like the following snippet.

    #[derive(rustler::NifEnum)]
    enum Test {
      Foo{ x: i32, y: i32 }, // Allow named enum
      Bar(String),
      Baz(String),  // Allow duplicated types
      Qux
    }
    
    #[rustler::nif]
    fn claim_test(value: i32) -> Test {
      match value {
        0 => Test::Foo{ x: 1, y: 2 },        // %{__enum__: :foo, x: 1, y: 2}
        1 => Test::Bar("Hello".to_string()), // {:bar, "Hello"}
        2 => Test::Baz("world".to_string()), // {:baz, "world"}
        3 => Test::Qux,                      // :qux
        _ => panic!("")
      }
    }
    

    If there are more idiomatic ways to bind, please let me know!

    Also, I didn't realize there was a related issue, #426. I'm really sorry about that 🙏

    opened by SeokminHong 24
  • Fix build issues on Mac

    Fix build issues on Mac

    Not sure if this is a OS X-specific issue:

    Cargo.toml

    [package]
    name = "rustler_test"
    version = "0.1.0"
    authors = []
    
    [lib]
    name = "rustler_test"
    path = "src/nif.rs"
    crate_type = ["dylib"]
    
    [dependencies]
    rustler = "0.8.1"
    rustler_codegen = "0.8.1"
    

    src/nif.rs

    #![feature(plugin)]
    #![plugin(rustler_codegen)]
    
    #[macro_use]
    extern crate rustler;
    use rustler::{ NifEnv, NifTerm, NifResult, NifEncoder };
    
    rustler_export_nifs!(
        "Elixir.RustlerTest",
        [("add", 2, add)],
        None
    );
    
    fn add<'a>(env: &'a NifEnv, args: &Vec<NifTerm>) -> NifResult<NifTerm<'a>> {
        let num1: i64 = try!(args[0].decode());
        let num2: i64 = try!(args[1].decode());
        Ok((num1 + num2).encode(env))
    }
    
    $ multirust run nightly-2016-04-05 mix rustler.check
    Rustler environment verified
    $ multirust run nightly-2016-04-05 cargo build
       Compiling lazy_static v0.1.16
       Compiling easy-plugin v0.3.0
       Compiling aster v0.14.0
       Compiling libc v0.2.10
       Compiling ruster_unsafe v0.4.0
       Compiling rustler v0.8.1
       Compiling rustler_codegen v0.8.1
       Compiling rustler_test v0.1.0 (file:///Users/brendan/code/dev-day/elixir_rustler_test)
    error: linking with `cc` failed: exit code: 1
    note: "cc" "-m64" "-L" "/Users/brendan/.multirust/toolchains/nightly-2016-04-05/lib/rustlib/x86_64-apple-darwin/lib" "/Users/brendan/code/dev-day/elixir_rustler_test/target/debug/rustler_test.0.o" "-o" "/Users/brendan/code/dev-day/elixir_rustler_test/target/debug/librustler_test.dylib" "/Users/brendan/code/dev-day/elixir_rustler_test/target/debug/rustler_test.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/brendan/code/dev-day/elixir_rustler_test/target/debug" "-L" "/Users/brendan/code/dev-day/elixir_rustler_test/target/debug/deps" "-L" "/Users/brendan/.multirust/toolchains/nightly-2016-04-05/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/librustler-12f16f7939d96e54.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/libruster_unsafe-badf32d60ecc0604.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/liblibc-30c6b6751f89189b.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/liblazy_static-5e6d9f365bf63baa.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/libstd-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/libcollections-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/librustc_unicode-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/librand-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/liballoc-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/liballoc_system-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/liblibc-18402db3.rlib" "-Wl,-force_load,/var/folders/z3/g4m3xbnj11q6m76kzg8w683c0000gn/T/rustc.QBlM3AicSUqg/libcore-18402db3.rlib" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib" "-l" "compiler-rt"
    note: Undefined symbols for architecture x86_64:
      "_enif_make_double", referenced from:
          rustler::wrapper::nif_interface::enif_make_double::hd19548d32bb32295 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$f64$u20$as$u20$types..NifEncoder$GT$::encode::h706149e7449ffee2 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$f32$u20$as$u20$types..NifEncoder$GT$::encode::h144f24ce0170a8e0 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_ulong", referenced from:
          ruster_unsafe::enif_get_uint64::h64c3175e0dbcd390 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          ruster_unsafe::enif_get_uint64::h64c3175e0dbcd390 in libruster_unsafe-badf32d60ecc0604.rlib(ruster_unsafe-badf32d60ecc0604.0.o)
      "_enif_make_ulong", referenced from:
          ruster_unsafe::enif_make_uint64::h4fba0e724d8e25b6 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          ruster_unsafe::enif_make_uint64::h4fba0e724d8e25b6 in libruster_unsafe-badf32d60ecc0604.rlib(ruster_unsafe-badf32d60ecc0604.0.o)
      "_enif_make_long", referenced from:
          ruster_unsafe::enif_make_int64::hbc1979f2890ffe9c in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          ruster_unsafe::enif_make_int64::hbc1979f2890ffe9c in libruster_unsafe-badf32d60ecc0604.rlib(ruster_unsafe-badf32d60ecc0604.0.o)
      "_enif_get_uint", referenced from:
          rustler::wrapper::nif_interface::enif_get_uint::h5c5a16f0a01fde37 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::haf5c58d5060cb07f in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u8$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h3e7e1bef75d03b42 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u16$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h1e7efa45cf0cba98 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_int", referenced from:
          rustler::wrapper::nif_interface::enif_get_int::hc379e848b0f1fa91 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h1c37e7be14e575ae in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i8$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::ha035f42162eb16a1 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i16$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h5a81998157625a57 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_int", referenced from:
          rustler::wrapper::nif_interface::enif_make_int::h60d93b2ae4a8c8d3 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i32$u20$as$u20$types..NifEncoder$GT$::encode::h7ddd4380fe5dda18 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i8$u20$as$u20$types..NifEncoder$GT$::encode::hdc7675ac9b527c9f in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$i16$u20$as$u20$types..NifEncoder$GT$::encode::hb0da2bfd44111ec8 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_keep_resource", referenced from:
          rustler::wrapper::nif_interface::enif_keep_resource::hcf8953a093156f6c in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_release_resource", referenced from:
          rustler::wrapper::nif_interface::enif_release_resource::hcddf0787bf6dbeeb in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_atom_len", referenced from:
          rustler::wrapper::nif_interface::enif_make_atom_len::he20a8a9702701fff in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_resource", referenced from:
          rustler::wrapper::nif_interface::enif_get_resource::h47d539fa331c39f3 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_resource", referenced from:
          rustler::wrapper::nif_interface::enif_make_resource::hb81c16919c920cad in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_alloc_resource", referenced from:
          rustler::wrapper::nif_interface::enif_alloc_resource::h68237ee990d1cf46 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_uint", referenced from:
          rustler::wrapper::nif_interface::enif_make_uint::hfe8668de47444792 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u32$u20$as$u20$types..NifEncoder$GT$::encode::h868c09d12496aeec in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u8$u20$as$u20$types..NifEncoder$GT$::encode::h11ad232d66e87a7d in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$u16$u20$as$u20$types..NifEncoder$GT$::encode::h201a5388c8670d75 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_map_update", referenced from:
          rustler::wrapper::nif_interface::enif_make_map_update::hf5941f5f4b1d847b in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_map_value", referenced from:
          rustler::wrapper::nif_interface::enif_get_map_value::hc296d9a0bd30c233 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_map_put", referenced from:
          rustler::wrapper::nif_interface::enif_make_map_put::ha859d99862427ecd in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_open_resource_type", referenced from:
          rustler::wrapper::nif_interface::enif_open_resource_type::h12583a80f65f5745 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_new_map", referenced from:
          rustler::wrapper::nif_interface::enif_make_new_map::h907851f26b8541d0 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_badarg", referenced from:
          rustler::wrapper::nif_interface::enif_make_badarg::h4841a4ca720a65e5 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_tuple", referenced from:
          rustler::wrapper::nif_interface::enif_get_tuple::h7fd11d0d72fa7d45 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_long", referenced from:
          ruster_unsafe::enif_get_int64::hebc458f802f3215b in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          ruster_unsafe::enif_get_int64::hebc458f802f3215b in libruster_unsafe-badf32d60ecc0604.rlib(ruster_unsafe-badf32d60ecc0604.0.o)
      "_enif_get_map_size", referenced from:
          rustler::wrapper::nif_interface::enif_get_map_size::h3f9747fdd9d0f47c in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_tuple_from_array", referenced from:
          rustler::wrapper::nif_interface::enif_make_tuple_from_array::h7befd54d882d7531 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_map_remove", referenced from:
          rustler::wrapper::nif_interface::enif_make_map_remove::h961aa87e2152ef7f in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_is_atom", referenced from:
          rustler::wrapper::nif_interface::enif_is_atom::h334838d6a8353d15 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_copy", referenced from:
          rustler::wrapper::nif_interface::enif_make_copy::h810279a726029774 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_inspect_binary", referenced from:
          rustler::wrapper::nif_interface::enif_inspect_binary::h060c7c6692faf746 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          rustler::binary::NifBinary::from_term::h00da1e274a0cd422 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_alloc_env", referenced from:
          rustler::wrapper::nif_interface::enif_alloc_env::h3fd2c1de3d6068bc in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_make_binary", referenced from:
          rustler::wrapper::nif_interface::enif_make_binary::hdd6097cc32618309 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          rustler::binary::NifBinary::from_owned::h538759bc101b2b41 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_alloc_binary", referenced from:
          rustler::wrapper::nif_interface::enif_alloc_binary::h08bb424d3fa65f76 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          rustler::binary::OwnedNifBinary::alloc::hf56f1176ed8c3872 in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_release_binary", referenced from:
          rustler::wrapper::nif_interface::enif_release_binary::hcd3611ded3fa4e8e in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$binary..OwnedNifBinary$u20$as$u20$std..ops..Drop$GT$::drop::hce6f374d6af3cdab in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_get_double", referenced from:
          rustler::wrapper::nif_interface::enif_get_double::h0954e2466735bdec in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$f64$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h3c4a4cbd31f2a5df in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
          _$LT$f32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h7abf1a0ce08162cb in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
      "_enif_raise_exception", referenced from:
          rustler::wrapper::nif_interface::enif_raise_exception::hfb9038fb735943ae in librustler-12f16f7939d96e54.rlib(rustler-12f16f7939d96e54.0.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    error: aborting due to previous error
    error: Could not compile `rustler_test`.
    
    To learn more, run the command again with --verbose.
    
    opened by brendanzab 23
  • Taking a look at html5ever parsing

    Taking a look at html5ever parsing

    I did a google and your name came up! Did you ever have a quick stab at this? I have a feeling it would be very useful and much better than :mochiweb. With Rustler it should also be quite safe too.

    The structure that Floki uses for parsed html looks about what we want out of html5ever and fairly simple...

    question 
    opened by aphillipo 18
  • Running `mix test` does not work on the first run (needs to compile twice)

    Running `mix test` does not work on the first run (needs to compile twice)

    [Modify the `mix.exs` file]
    
    $ mix test
    Compiling NIF crate :rustler_test (native/rustler_test)...
        Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
    Compiling 221 files (.ex)
    
    13:15:37.820 [warn]  The on_load function for module Elixir.RustlerTest returned:
    {:error, {:upgrade, 'Upgrade not supported by this NIF library.'}}
    
    [Tests fail]
    
    [Then, running again works]
    
    $ mix test
    
    [Tests succeed]
    

    To make it work in travis CI I had to compile before running the tests:

     - MIX_ENV=test mix compile
     - mix test || travis_terminate 1
    

    Same issue happens when trying to open the console with: iex -S mix

    Rustler compiler is in the recommended order: compilers: [:rustler, :phoenix, :gettext] ++ Mix.compilers,

    opened by rafapaez 16
  • NIF panics when producing too much input in too short of a time

    NIF panics when producing too much input in too short of a time

    Not sure if there is any way to actually fix this. This is probably because Erlang has stdout set to non-blocking mode, and a buffer gets filled up somewhere.

    opened by hansihe 16
  • Rustler Compiled Library is Missing

    Rustler Compiled Library is Missing

    Hi, thanks for starting this great open source project!

    Brief

    I am using rustler as a nested dependency, and since v0.22.0rc, which I am using via pulling master branch, I think the new compilation approach doesn't copy the files correctly when creating a release. It works when I try to run the same release command twice or more, though.

    Output

    Code

    defmodule DamaLogic.NifBridge do
      use Rustler, otp_app: :dama_logic, crate: "damalogic_damaprocess"
    
      [...]
    end
    

    Running mix release for the first time in a clean docker environment.

    During compilation

    226	
    227	03:31:43.683 [warn]  The on_load function for module Elixir.DamaLogic.NifBridge returned:
    228	{:error, {:load_failed, 'Failed to load NIF library: \'/work/_build/prod/lib/dama_logic/priv/native/libdamalogic_damaprocess.so: cannot open shared object file: No such file or directory\''}}
    229	
    230	Generated dama_logic app
    231	
    

    After compilation

    Running find . -iname '*.so'

    ./deps/dama_logic/priv/native/libdamalogic_damaprocess.so
    
    ./_build/prod/rel/dama_server/lib/runtime_tools-1.14/priv/lib/trace_ip_drv.so
    ./_build/prod/rel/dama_server/lib/runtime_tools-1.14/priv/lib/dyntrace.so
    ./_build/prod/rel/dama_server/lib/runtime_tools-1.14/priv/lib/trace_file_drv.so
    ./_build/prod/rel/dama_server/lib/crypto-4.6.5/priv/lib/crypto.so
    ./_build/prod/rel/dama_server/lib/crypto-4.6.5/priv/lib/crypto_callback.so
    ./_build/prod/rel/dama_server/lib/crypto-4.6.5/priv/lib/otp_test_engine.so
    
    ./_build/prod/lib/dama_logic/native/damalogic_damaprocess/release/deps/libdamalogic_damaprocess.so
    ./_build/prod/lib/dama_logic/native/damalogic_damaprocess/release/deps/librustler_codegen-1426f88bc646ec0e.so
    ./_build/prod/lib/dama_logic/native/damalogic_damaprocess/release/libdamalogic_damaprocess.so
    

    (Newlines added by me for clarity)

    Expectation

    I would expect the output of the *.so to be within the _build directory instead of the deps directory given that :build_embedded is set to true. If the priv copying is happening before compilation, I guess this would cause the issue of breaking only during the first attempt of generating a release?

    I will attempt to make a small repro repo once I get around to it.

    Thanks,

    opened by Mazyod 14
  • implement NifEncoder for Option<T> and Result<T,E>

    implement NifEncoder for Option and Result

    Implementation for built-in types:

    Option::Some(value) is_encoded as value_encoded Option::None is encoded as :nil Result::Ok(value) is encoded as {:ok, value_encoded} Result::Err(err) is serialized as {:error, err_encoded}

    opened by alex-shapiro 14
  • ** (Mix) NIF version 2.11 is not supported by Rustler. See https://github.com/hansihe/Rustler/blob/master/FAQ.md#unsuppored-nif-version

    ** (Mix) NIF version 2.11 is not supported by Rustler. See https://github.com/hansihe/Rustler/blob/master/FAQ.md#unsuppored-nif-version

    $ mix rustler.check
    ** (Mix) NIF version 2.11 is not supported by Rustler. See https://github.com/hansihe/Rustler/blob/master/FAQ.md#unsuppored-nif-version
    

    And yet I have Erlang 19, definitely not old by any stretch, although has been out for a while now.

    opened by OvermindDL1 13
  • switch to rustup instead of multirust

    switch to rustup instead of multirust

    The required version of rustc is only a week old, but still you are trying to use a version manager that is deprecated in favor of rustup for about half a year

    opened by NobbZ 13
  • Generic types

    Generic types

    Fixes #424 . I'm trying to implement support for generic/polymorphic types. Can you give me some feedback whether I'm on the right track? If yes, I'll proceed with the other macros.

    opened by turion 12
  • Define MSRV and fix lints

    Define MSRV and fix lints

    This pull requests defines a MSRV (1.56.1) for rustler. The MSRV is restricted by the use of edition 2021 in rustler_bigint. With that, we can restrict the lints clippy emits to only those which can also be fixed for the MSRV.

    opened by evnu 0
  • Check if Term is float

    Check if Term is float

    Hello!

    First of all, wanted to say this project is amazing, I'm a newbie at Rust and I was still able to write a nif and use it in Elixir!

    While most of what I was set to code is working, there is one more thing I couldn't crack.

    The nif I'm working on receives an Elixir map as an argument. The map can have different kinds of values (maps, lists, booleans, ints, floats, etc).

    While decoding the Map as a Rust Struct, I'm having issues while decoding numbers. Since the map is dynamic, I don't know beforehand if the value I'm going to decode is an int or a float, and I haven't been able to make this work for both ints and floats at the same time.

    This is the code I have:

    if term.is_number() {
       let number_scalar: f64 = term.decode::<f64>().unwrap();
       ...
    }
    ...
    

    In order to call the right decoder, I need to specify the type but given I don't know the type, I can't do that. I checked rustler and there is no term.is_float or term.is_int which could help me out.

    I imagine the possibility of doing something like:

    if term.is_int() {
       let number_scalar: i32 = term.decode::<i32>().unwrap();
       ...
    } else if term.is_float() {
      let number_scalar: f64 = term.decode::<f64>().unwrap();
    }
    

    Is this possible? if it's not, does anybody has any recommendations on how to handle this case?

    opened by juanazam 5
  • rustler: add a Rust type `ErlOption<T>`

    rustler: add a Rust type `ErlOption`

    This PR fixes #500 by adding a Rust typeErlOption<T> to the Rustler crate.

    ErlOption<T> is a wrapper around Option<T>. It implements Rustler's Encoder and Decoder, and serializes None into undefined atom instead of nil. The undefined atom is commonly used in Erlang libraries to express the absence of a value.

    For convenience, ErlOption<T> implements some traits from std, so that it will be easy to get a reference of enclosing Option<T> or convert from/to Option<T>. Here are the examples from its doc:

    use rustler::ErlOption;
    
    // Create new `ErlOption<i32>` values via convenient functions.
    let _ = ErlOption::some(1); // Wraps `Some(1)`.
    let _ = ErlOption::<i32>::none();
    
    // Convert Option<i32> values to ErlOption<i32> values.
    let _ = ErlOption::from(Some(2));
    let _: ErlOption<_> = Some(3).into();
    let _: ErlOption<i32> = None.into();
    
    // Get a reference of enclosing Option<T> from an ErlOption<T>.
    let _: &Option<i32> = ErlOption::some(4).as_ref();
    
    // Get a mutable reference of enclosing Option<T> from an ErlOption<T>.
    let _: &mut Option<i32> = ErlOption::some(5).as_mut();
    
    // Convert an ErlOption<i32> value to an Option<i32> value.
    let _: Option<i32> = ErlOption::some(6).into();
    
    // Compare ErlOption<T> with Option<T>.
    assert_eq!(ErlOption::some(7), Some(7));
    assert!(ErlOption::some(8) > Some(7));
    
    // Call Option<T>'s methods on an ErlOption<T> via Deref and DerefMut.
    assert!(ErlOption::some(9).is_some());
    assert_eq!(ErlOption::some(10).unwrap(), 10);
    assert_eq!(ErlOption::some(12).map(|v| v + 1), ErlOption::some(13));
    
    opened by tatsuya6502 1
  • Elixir errors using Rust's `?`

    Elixir errors using Rust's `?`

    Hi,

    First of all, Rustler is awesome, creating the NIF seems much simplified compared to C!

    I was wondering about what would be the best practice for errors, in particular it would be nice to have errors using ?. I have put together a repo for it at https://github.com/KoviRobi/rustler_raise_error and I was wondering if there is an easier way to do it?

    It's possible my whole use-case/assumptions are wrong, of course, and this isn't the right way to go about handling errors. What I wanted is an easy way to do errors that are semi user-understandable (not necessarily in normal English but a tech person should be able to figure it out). Here is what I got:

    1. Using the {:ok, _}, {:error, _} paradigm

      iex(1)> NIF.getenv("FOO")
      {:error, "Variable not set: environment variable not found"}
      

      Note that this paradigm doesn't need the wrapper. I've just used one so that I can also reuse it for getenv!. But thinking about this, the whole thing wouldn't be so bad if we could reuse the function definition for the non-! version (currently it's impossible because the definition is hidden behind a structure).

    2. Using the exceptions paradigm -- this also shows what advantage it might have over {:ok, _} = ... which is printing the arguments the function was called with.

      iex(2)> NIF.getenv!("FOO")
      ** (ErlangError) Erlang error: "Variable not set: environment variable not found"
          (rustler_raise_error 0.1.0) NIF.getenv!("FOO")
      iex(2)> {:ok, value} = NIF.getenv("FOO")
      ** (MatchError) no match of right hand side value: {:error, "Variable not set: environment variable not found"}
      

    This also brought up the question, is there a way to have functions in Rustler that have ! in them? I tried doing

    #[nif(name = "getenv!")]
    

    but that didn't seem to work, it failed with

    error: custom attribute panicked
      --> src/lib.rs:64:1
       |
    64 | #[nif(name = "getenv!")]
       | ^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = help: message: `"getenv!"` is not a valid identifier
    

    which seems like a bug? I've had a go at solving it in https://github.com/rusterlium/rustler/pull/505

    opened by KoviRobi 5
  • Allow arbitrary NIF names (e.g. those ending with `!` or `?`)

    Allow arbitrary NIF names (e.g. those ending with `!` or `?`)

    There is as far as I know, no reason for the erlang function name to be an identifier.

    To use, do

    \#[nif(name = "foo!")]
    fn foo_bang(...) -> ... {
        ...
    }
    
    opened by KoviRobi 2
  • Option to exclude or ignore specific artifacts

    Option to exclude or ignore specific artifacts

    First of all, thank you for creating Rustler! I really enjoy using it.

    I have a Cargo.toml that looks something like this:

    [package]
    name = "name"
    
    [lib]
    name = "name"
    path = "src/lib.rs"
    crate-type = ["cdylib"]
    
    [[bin]]
    name = "name-bin"
    path = "src/main.rs"
    required-features = ["build-binary"]
    

    I use the lib artifact in my Elixir code, and I use the bin artifact to debug the lib with some GUI stuff that's not needed in the lib artifact (prevents fetching and compiling unneeded dependencies).

    Once it has successfully compiled, Rustler tries to copy all artifacts:

    ** (File.CopyError) could not copy from "/app/_build/prod/lib/xx/native/name/release/name-bin" to "priv/native/name-bin": no such file or directory
        (elixir 1.14.0) lib/file.ex:838: File.cp!/3
        (elixir 1.14.0) lib/enum.ex:975: Enum."-each/2-lists^foreach/1-0-"/2
        (rustler 0.26.0) lib/rustler/compiler.ex:44: Rustler.Compiler.compile_crate/2
        ...
    

    This is not desired because I only need the lib, which has successfully compiled. Instead, my build failed because not every artifact was compiled.

    Related Rustler code: https://github.com/rusterlium/rustler/blob/rustler-0.26.0/rustler_mix/lib/rustler/compiler.ex#L178 https://github.com/rusterlium/rustler/blob/rustler-0.26.0/rustler_mix/lib/rustler/compiler.ex#L197

    My personal preference would go to a solution like this: Continue to try to copy all possible artifacts, but give a warning instead of halting the Rustler compile process when a specific artifact doesn't exist (but maybe require at least one artifact per package?). I'm also ok with a solution that allows people to exclude/include specific artifacts.

    opened by Tim203 2
Releases(rustler-0.26.0)
  • rustler-0.26.0(Sep 13, 2022)

    What's Changed

    • Improve documentation of derive macros by @turion in https://github.com/rusterlium/rustler/pull/429
    • Document the usage of schedule flag for nif macro by @philss in https://github.com/rusterlium/rustler/pull/444
    • Update links in the docs and bump ex_doc by @philss in https://github.com/rusterlium/rustler/pull/445
    • Fix compilation error of Result alias by @SeokminHong in https://github.com/rusterlium/rustler/pull/448
    • Support more generalized macro for enum by @SeokminHong in https://github.com/rusterlium/rustler/pull/440
    • ci: Test OTP 25 and remove OTP 22 by @evnu in https://github.com/rusterlium/rustler/pull/455
    • Change map helper functions' arguments by @SeokminHong in https://github.com/rusterlium/rustler/pull/453
    • Migrate GitHub Actions to erlef/setup-beam by @kianmeng in https://github.com/rusterlium/rustler/pull/457
    • Adds Env.whereis_pid by @Qqwy in https://github.com/rusterlium/rustler/pull/456
    • Fix moving out terms by @SeokminHong in https://github.com/rusterlium/rustler/pull/458
    • Add support for large integers by @thomas9911 in https://github.com/rusterlium/rustler/pull/454
    • Prepare rustler_bigint release by @evnu in https://github.com/rusterlium/rustler/pull/465
    • Disambiguate encode and decode by @SeokminHong in https://github.com/rusterlium/rustler/pull/466
    • Support .toml file extension for .cargo/config.toml by @evnu in https://github.com/rusterlium/rustler/pull/468
    • Derive Clone and Copy for TermType by @dvic in https://github.com/rusterlium/rustler/pull/476
    • Tagged enum usability & performance improvements by @cleaton in https://github.com/rusterlium/rustler/pull/482
    • Fix lifetime handling in rustler_codegen by @evnu in https://github.com/rusterlium/rustler/pull/483

    New Contributors

    • @turion made their first contribution in https://github.com/rusterlium/rustler/pull/429
    • @SeokminHong made their first contribution in https://github.com/rusterlium/rustler/pull/448
    • @Qqwy made their first contribution in https://github.com/rusterlium/rustler/pull/456
    • @dvic made their first contribution in https://github.com/rusterlium/rustler/pull/476
    • @cleaton made their first contribution in https://github.com/rusterlium/rustler/pull/482

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.25.0...rustler-0.26.0

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.25.0(Sep 13, 2022)

    What's Changed

    • import NewBinary in lib by @ayrat555 in https://github.com/rusterlium/rustler/pull/436
    • Add Term::map_from_pairs by @philss in https://github.com/rusterlium/rustler/pull/437
    • Fix macos target in warning by @evnu in https://github.com/rusterlium/rustler/pull/438
    • Abort compilation on macos if linker arguments are missing by @evnu in https://github.com/rusterlium/rustler/pull/439
    • ci: Add macos runner by @evnu in https://github.com/rusterlium/rustler/pull/401
    • Fix snake case warnings for rust analyzer by @philss in https://github.com/rusterlium/rustler/pull/441
    • Fix year in changelog entry by @sickill in https://github.com/rusterlium/rustler/pull/442

    New Contributors

    • @ayrat555 made their first contribution in https://github.com/rusterlium/rustler/pull/436
    • @sickill made their first contribution in https://github.com/rusterlium/rustler/pull/442

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.24.0...rustler-0.25.0

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.24.0(Sep 13, 2022)

    What's Changed

    • Change supported Elixir and OTP versions by @philss in https://github.com/rusterlium/rustler/pull/415
    • Fix typos by @kianmeng in https://github.com/rusterlium/rustler/pull/420
    • Remove superfluous 'extern crate' by @evnu in https://github.com/rusterlium/rustler/pull/422
    • Bump heck to 0.4 by @evnu in https://github.com/rusterlium/rustler/pull/421
    • Relax Jason version requirement to ~> 1.0 by @aj-foster in https://github.com/rusterlium/rustler/pull/427
    • file extensions should be set based on the compile target by @cocoa-xu in https://github.com/rusterlium/rustler/pull/423
    • add NewBinary (enif_make_new_binary) by @dlesl in https://github.com/rusterlium/rustler/pull/379
    • Make TermType derive Eq and PartialEq by @hammsvietro in https://github.com/rusterlium/rustler/pull/432
    • Rustler v0.24 by @evnu in https://github.com/rusterlium/rustler/pull/435

    New Contributors

    • @aj-foster made their first contribution in https://github.com/rusterlium/rustler/pull/427
    • @cocoa-xu made their first contribution in https://github.com/rusterlium/rustler/pull/423
    • @hammsvietro made their first contribution in https://github.com/rusterlium/rustler/pull/432

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.23.0...rustler-0.24.0

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.23.0(Sep 13, 2022)

    What's Changed

    • Define supported versions of OTP and Elixir by @evnu in https://github.com/rusterlium/rustler/pull/387
    • Remove DUMMY variant from ErlNifCharEncoding by @evnu in https://github.com/rusterlium/rustler/pull/390
    • codegen: change RaiseAtom to RaiseTerm by @dlesl in https://github.com/rusterlium/rustler/pull/378
    • Crash if metadata cannot be retrieved by @evnu in https://github.com/rusterlium/rustler/pull/398
    • Remove remaning code from unsupported NIF versions by @philss in https://github.com/rusterlium/rustler/pull/395
    • cargo config for all macos architectures by @scrogson in https://github.com/rusterlium/rustler/pull/396
    • Add NifException macro by @thomas9911 in https://github.com/rusterlium/rustler/pull/383
    • Require step for range by @evnu in https://github.com/rusterlium/rustler/pull/399
    • ci: Test against v1.12 by @evnu in https://github.com/rusterlium/rustler/pull/393
    • Rewrite build of NIF APIs in Rust by @philss in https://github.com/rusterlium/rustler/pull/397
    • Add FreeBSD support by @madninja in https://github.com/rusterlium/rustler/pull/404
    • Fix unused var warning - rustler_mix by @philss in https://github.com/rusterlium/rustler/pull/407
    • Implement Hash and [Partial]Eq for binary types by @JayKickliter in https://github.com/rusterlium/rustler/pull/400
    • implement hashing for term (rebased) by @hazardfn in https://github.com/rusterlium/rustler/pull/410
    • Fix "mix rustler.new" on Elixir 1.13 by @philss in https://github.com/rusterlium/rustler/pull/414
    • Test mix rustler.new with Elixir v1.13 by @evnu in https://github.com/rusterlium/rustler/pull/416
    • Prepare CHANGELOG for v0.23 by @evnu in https://github.com/rusterlium/rustler/pull/418

    New Contributors

    • @madninja made their first contribution in https://github.com/rusterlium/rustler/pull/404
    • @hazardfn made their first contribution in https://github.com/rusterlium/rustler/pull/410

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.22.2...rustler-0.23.0

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.22.2(Sep 13, 2022)

    What's Changed

    • Don't call cargo when skip_compilation? is true by @karolsluszniak in https://github.com/rusterlium/rustler/pull/389

    New Contributors

    • @karolsluszniak made their first contribution in https://github.com/rusterlium/rustler/pull/389

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.22.1...rustler-0.22.2

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.22.1(Sep 13, 2022)

    What's Changed

    • Replace release.sh with prepare_release.sh by @evnu in https://github.com/rusterlium/rustler/pull/369
    • Fix clippy by @evnu in https://github.com/rusterlium/rustler/pull/372
    • Fix generic types for untagged enum codegen by @evnu in https://github.com/rusterlium/rustler/pull/371
    • Allow specifying a channel for the system rustc by @jflatow in https://github.com/rusterlium/rustler/pull/347
    • Fix project repo URL in error message by @ericlathrop in https://github.com/rusterlium/rustler/pull/373
    • Point to HexDocs base URL for Rustler in lib.rs by @brainsnail in https://github.com/rusterlium/rustler/pull/384
    • Extend rustler_mix to handle local dependencies with external_resources by @evnu in https://github.com/rusterlium/rustler/pull/386

    New Contributors

    • @jflatow made their first contribution in https://github.com/rusterlium/rustler/pull/347
    • @ericlathrop made their first contribution in https://github.com/rusterlium/rustler/pull/373
    • @brainsnail made their first contribution in https://github.com/rusterlium/rustler/pull/384

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.22.0...rustler-0.22.1

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.22.0(Sep 13, 2022)

    What's Changed

    • Fix module namespace by @mfeckie in https://github.com/rusterlium/rustler/pull/237
    • Fix a Clippy warning (Clippy 0.0.212 / Rust 1.38.0) by @tatsuya6502 in https://github.com/rusterlium/rustler/pull/242
    • Update unreachable requirement from 0.1 to 1.0 by @dependabot-preview in https://github.com/rusterlium/rustler/pull/243
    • Remove superfluous use statements from proc-macros by @evnu in https://github.com/rusterlium/rustler/pull/240
    • Update which requirement from 2 to 3 by @dependabot-preview in https://github.com/rusterlium/rustler/pull/247
    • Bump dependencies and refactor attribute retrieval by @evnu in https://github.com/rusterlium/rustler/pull/234
    • Support target pointer width. by @scrogson in https://github.com/rusterlium/rustler/pull/233
    • Replace mem::uninitialized by MaybeUninit by @filmor in https://github.com/rusterlium/rustler/pull/239
    • Fall back to precompiled API snippet if gen_api.erl fails by @filmor in https://github.com/rusterlium/rustler/pull/238
    • Rename macros by @scrogson in https://github.com/rusterlium/rustler/pull/249
    • Add a simple Debug impl for Error by @filmor in https://github.com/rusterlium/rustler/pull/248
    • use $crate::Term in init! macro by @scrogson in https://github.com/rusterlium/rustler/pull/255
    • Refactor codegen by @evnu in https://github.com/rusterlium/rustler/pull/251
    • codegen: Support newtype and tuple structs by @evnu in https://github.com/rusterlium/rustler/pull/259
    • GitHub Actions by @scrogson in https://github.com/rusterlium/rustler/pull/253
    • Fix Binary Compilation by @scrogson in https://github.com/rusterlium/rustler/pull/261
    • Deduplicate field atoms by @evnu in https://github.com/rusterlium/rustler/pull/257
    • Adjust the test matrix by @scrogson in https://github.com/rusterlium/rustler/pull/262
    • Instruct on :rustler instead :rustler_mix by @BurntCaramel in https://github.com/rusterlium/rustler/pull/265
    • Test rustler_mix generated files by @evnu in https://github.com/rusterlium/rustler/pull/266
    • rustler_mix: Mix format by @evnu in https://github.com/rusterlium/rustler/pull/268
    • rustler_mix: Fix template test on Elixir < 1.9 by @evnu in https://github.com/rusterlium/rustler/pull/269
    • Revamp rustler_mix documentation by @evnu in https://github.com/rusterlium/rustler/pull/270
    • Fix replacing rustler version in release script by @evnu in https://github.com/rusterlium/rustler/pull/267
    • Delete config.exs by @josevalim in https://github.com/rusterlium/rustler/pull/271
    • NIF Codegen rework by @scrogson in https://github.com/rusterlium/rustler/pull/264
    • Added Error::Term for returning {:error, <term>} by @elbow-jason in https://github.com/rusterlium/rustler/pull/252
    • Test renaming a NIF by @evnu in https://github.com/rusterlium/rustler/pull/278
    • Validate NIF attributes by @evnu in https://github.com/rusterlium/rustler/pull/279
    • Update Github workflow for clippy/rustfmt by @filmor in https://github.com/rusterlium/rustler/pull/273
    • Windows long is always 4 bytes wide by @filmor in https://github.com/rusterlium/rustler/pull/285
    • Do not include toml in runtime by @evnu in https://github.com/rusterlium/rustler/pull/288
    • Make OwnedBinary NifReturnable by @szlend in https://github.com/rusterlium/rustler/pull/289
    • Fix Segfault in OwnedEnv::send_and_clear by @scrogson in https://github.com/rusterlium/rustler/pull/291
    • Rename Pid to LocalPid by @filmor in https://github.com/rusterlium/rustler/pull/292
    • Revert "Remove superfluous use statements from proc-macros (#240)" by @evnu in https://github.com/rusterlium/rustler/pull/298
    • Drop dependency on 'which' crate by @evnu in https://github.com/rusterlium/rustler/pull/295
    • Tag releases and make release script more resilient by @evnu in https://github.com/rusterlium/rustler/pull/280
    • Derive Debug for rustler::dynamic::TermType by @evnu in https://github.com/rusterlium/rustler/pull/301
    • Allow using reserved keywords as field names in codegen by @evnu in https://github.com/rusterlium/rustler/pull/303
    • Speed up generated decoder compilation times by @evnu in https://github.com/rusterlium/rustler/pull/300
    • Remove lazy_static build dependency by @evnu in https://github.com/rusterlium/rustler/pull/304
    • Run github actions on windows-latest by @evnu in https://github.com/rusterlium/rustler/pull/305
    • Add Elixir v1.10 to github actions by @evnu in https://github.com/rusterlium/rustler/pull/306
    • Add changelog entries for v0.22 by @evnu in https://github.com/rusterlium/rustler/pull/277
    • Refactor compilation by @scrogson in https://github.com/rusterlium/rustler/pull/275
    • Bump earmark to v1.4.4 by @evnu in https://github.com/rusterlium/rustler/pull/309
    • Readd Copy and Clone on Binary by @filmor in https://github.com/rusterlium/rustler/pull/316
    • Remove superfluous parantheses by @evnu in https://github.com/rusterlium/rustler/pull/318
    • Implement Encode/Decode for HashMap by @evnu in https://github.com/rusterlium/rustler/pull/314
    • Make the generated nif_init private by @filmor in https://github.com/rusterlium/rustler/pull/322
    • Fix clippy lints by @evnu in https://github.com/rusterlium/rustler/pull/320
    • ci: Test OTP 23 by @evnu in https://github.com/rusterlium/rustler/pull/325
    • Fix clippy lint by @evnu in https://github.com/rusterlium/rustler/pull/328
    • Remove OwnedBinary's release flag by @JayKickliter in https://github.com/rusterlium/rustler/pull/327
    • Improve error messages on failure to derive by @JayKickliter in https://github.com/rusterlium/rustler/pull/329
    • Improve binary documentation by @JayKickliter in https://github.com/rusterlium/rustler/pull/330
    • Ignore target directory that produced by cargo by @wingyplus in https://github.com/rusterlium/rustler/pull/332
    • Fix warnings by @thiamsantos in https://github.com/rusterlium/rustler/pull/334
    • Fix clippy lints by @evnu in https://github.com/rusterlium/rustler/pull/337
    • ci: Use stable toolchain for clippy and format by @evnu in https://github.com/rusterlium/rustler/pull/341
    • Update rust linker flags to apply to macOS by @jtdowney in https://github.com/rusterlium/rustler/pull/340
    • ci: Fix adding erlang to PATH in windows runnner by @evnu in https://github.com/rusterlium/rustler/pull/342
    • ci: Run jobs on wednesday night by @evnu in https://github.com/rusterlium/rustler/pull/344
    • Fix clippy lints by @evnu in https://github.com/rusterlium/rustler/pull/346
    • ci: Switch from actions/setup-elixir to erlef/setup-elixir by @evnu in https://github.com/rusterlium/rustler/pull/349
    • Disable lint for rustler_sys_api by @evnu in https://github.com/rusterlium/rustler/pull/352
    • Fix f32 type conversion to be safe by @Virviil in https://github.com/rusterlium/rustler/pull/350
    • Upgrade to GitHub-native Dependabot by @dependabot-preview in https://github.com/rusterlium/rustler/pull/355
    • Duplicate "add" function in the docs. by @likeanocean in https://github.com/rusterlium/rustler/pull/356
    • Misc doc changes by @kianmeng in https://github.com/rusterlium/rustler/pull/353
    • Update supported NIF API version to 2.16 by @filmor in https://github.com/rusterlium/rustler/pull/358
    • Add workaround for missing lib by @evnu in https://github.com/rusterlium/rustler/pull/361
    • Add deprecation note to CHANGELOG by @evnu in https://github.com/rusterlium/rustler/pull/362
    • clippy: Allow breaking convention to avoid breaking change by @evnu in https://github.com/rusterlium/rustler/pull/366
    • Add UPGRADE.md for v0.22 by @evnu in https://github.com/rusterlium/rustler/pull/365
    • Set @version in Mixfile on release by @evnu in https://github.com/rusterlium/rustler/pull/367

    New Contributors

    • @mfeckie made their first contribution in https://github.com/rusterlium/rustler/pull/237
    • @tatsuya6502 made their first contribution in https://github.com/rusterlium/rustler/pull/242
    • @dependabot-preview made their first contribution in https://github.com/rusterlium/rustler/pull/243
    • @BurntCaramel made their first contribution in https://github.com/rusterlium/rustler/pull/265
    • @josevalim made their first contribution in https://github.com/rusterlium/rustler/pull/271
    • @elbow-jason made their first contribution in https://github.com/rusterlium/rustler/pull/252
    • @szlend made their first contribution in https://github.com/rusterlium/rustler/pull/289
    • @wingyplus made their first contribution in https://github.com/rusterlium/rustler/pull/332
    • @thiamsantos made their first contribution in https://github.com/rusterlium/rustler/pull/334
    • @jtdowney made their first contribution in https://github.com/rusterlium/rustler/pull/340
    • @Virviil made their first contribution in https://github.com/rusterlium/rustler/pull/350
    • @likeanocean made their first contribution in https://github.com/rusterlium/rustler/pull/356

    Full Changelog: https://github.com/rusterlium/rustler/compare/rustler-0.21.2...rustler-0.22.0

    Source code(tar.gz)
    Source code(zip)
  • rustler-0.21.0(Oct 16, 2019)

    Added

    • Support for OTP22.
    • Rust linting with clippy.
    • Support for decoding IOLists as binaries, Term::decode_as_binary.

    Changes

    • rustler_codegen is now reexported by the rustler crate. Depending on the rustler_codegen crate is deprecated.
    • erlang_nif-sys has been renamed to rustler_sys and vendored into the rustler repo.
    • Replaced the hand-rolled TOML parser in rustler_mix with the toml-elixir package.
    • Improve error messages for derived encoders/decoders.
    • Rust bool now corresponds only to booleans (false, true) in Elixir. Previously, nil and false were both decodable to bool. To use the previous behaviour, a Truthy newtype was introduced.
    Source code(tar.gz)
    Source code(zip)
Bridge the gap between Haskell and Rust

Curryrs Curryrs (a play on the name of Haskell Curry, rs for Rust libraries, and it's pronunciation couriers) is a library for providing easy to use b

Michael Gattozzi 296 Oct 18, 2022
📝 A template for creating WASM + Typescript + Rust workflow libraries.

Create Rust + TypeScript libraries with ease! PR'S WELCOMED! ✨ Inspiration I wanted to create a WebAssembly/Rust library with additional JS features,

Shaoru Ian Huang 25 Dec 24, 2022
A rust library containing typings and utility functions dealing with the Public specification of the Internet Computer.

IC Types Contributing Please follow the guidelines in the CONTRIBUTING.md document. Goal This library contains typings and utility functions dealing w

DFINITY 5 Nov 28, 2022
Call Swift functions from Rust with ease!

swift-rs Call Swift functions from Rust with ease! Setup After adding swift-rs to your project's Cargo.toml, some setup work must be done. Ensure your

null 68 Dec 26, 2022
Pedersen hashing functions with JS <> Rust interoperability

Pedersen Hash This library exposes the following functions: pub fn pedersen(x: &str, y: &str) -> String: Geometry version. pub fn starknet_pedersen(x:

Herodotus 2 Nov 17, 2022
Unstable wrapper API for winapi's Console Functions

maulingmonkey-console-winapi-wrappers Unstable wrapper API for winapi's Console Functions Quickstart # Cargo.toml [dependencies] maulingmonkey-console

null 3 Nov 26, 2021
Safe interop between Rust and C++

CXX — safe FFI between Rust and C++ This library provides a safe mechanism for calling C++ code from Rust and Rust code from C++, not subject to the m

David Tolnay 4.4k Jan 7, 2023
Safe Rust bindings to Lua 5.1

rust-lua Copyright 2014 Lily Ballard Description This is a set of Rust bindings to Lua 5.1. The goal is to provide a (relatively) safe interface to Lu

Lily Ballard 124 Jan 5, 2023
mruby safe bindings for Rust

mrusty. mruby safe bindings for Rust mrusty lets you: run Ruby 1.9 files with a very restricted API (without having to install Ruby) reflect Rust stru

Anima 200 Oct 12, 2022
Rust bindings for writing safe and fast native Node.js modules.

Rust bindings for writing safe and fast native Node.js modules. Getting started Once you have the platform dependencies installed, getting started is

The Neon Project 7k Jan 4, 2023
WebAssembly implementation from scratch in Safe Rust with zero dependencies

wain wain is a WebAssembly INterpreter written in Rust from scratch with zero dependencies. An implementation of WebAssembly. Features: No unsafe code

Linda_pp 328 Jan 2, 2023
A minimalist and safe ECS library for rust!

The full ECS (Entity-Component-System) library. Support an Open Source Developer! ♥️ Composed of two smaller libraries: world_dispatcher: the System p

Joël Lupien 124 Dec 19, 2022
Safe Rust <---> GraalVM Polyglot bindings using procedural macros

The class macro is the primary way to generate bindings to Java types; it will generate a struct (with generics if specified) that implements Pass and Receive and has all the methods you give stubs for. The methods generated can be used like normal rust methods, however mutability is not enforced. The fully-qualified type name should precede a block containing method and constructor stubs. Java primitives like char, int, and byte are aliased to corresponding Rust types.

Alec Petridis 33 Dec 28, 2022
A safe Rust FFI binding for the NVIDIA® Tools Extension SDK (NVTX).

NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications. Official documentation for NVIDIA®'s NVTX can be found here.

Spencer Imbleau 78 Jan 2, 2023
High-level memory-safe binding generator for Flutter/Dart <-> Rust

flutter_rust_bridge: High-level memory-safe binding generator for Flutter/Dart <-> Rust Want to combine the best between Flutter, a cross-platform hot

fzyzcjy 2.1k Dec 31, 2022
A memory safe Lua interpreter

Hematita Da Lua Hematita Da Lua is an interpreter for the scripting language Lua, written entirely in 100% safe Rust. Hematita is the portugese word f

Daniel 149 Dec 29, 2022
Slitter is a C- and Rust-callable slab allocator implemented primarily in Rust, with some C for performance or to avoid unstable Rust features.

Slitter is a less footgunny slab allocator Slitter is a classically structured thread-caching slab allocator that's meant to help write reliable long-

Backtrace Labs 133 Dec 5, 2022
A Rust crate for automatically generating C header files from Rust source file.

Please be aware that this crate is no longer actively maintained, please look into the much more feature rich cbindgen instead. rusty-cheddar rusty-ch

Sean Marshallsay 190 Nov 12, 2022
Rust-ffi-guide - A guide for doing FFI using Rust

Using unsafe for Fun and Profit A guide to traversing the FFI boundary between Rust and other languages. A rendered version is available here. This gu

Michael Bryan 261 Dec 1, 2022