View Source RustlerPrecompiled (rustler_precompiled v0.1.0)

Download and use precompiled NIFs with safety

Rustler Precompiled is a tool for library maintainers of libs that rely on Rustler. It helps by removing the need to have compilers installed in the user's machine.

Check the Precompilation Guide for details.

Example

defmodule MyNative do
  use RustlerPrecompiled,
    otp_app: :my_app,
    crate: "my_app_nif",
    base_url: "https://github.com/me/my_project/releases/download/v0.1.0",
    version: "0.1.0"
end

Options

  • :otp_app - The OTP app name that the dynamic library will be loaded from.
  • :crate - The name of Rust crate if different from the :otp_app. This is optional.
  • :base_url - A valid URL that is used as base path for the NIF file.
  • :version - The version to be used. This is important since it compose the NIF file name.

Link to this section Summary

Functions

Returns URLs for NIFs based on its module name

List all default available targets

Returns the file URL to be downloaded for current target

Returns the target triple for download or compile and load.

Link to this section Functions

Link to this function

available_nif_urls(nif_module)

View Source

Returns URLs for NIFs based on its module name

The module name is the one that defined the NIF and this information is stored in a metadata file.

List all default available targets

Link to this function

current_target_nif_url(nif_module)

View Source

Returns the file URL to be downloaded for current target

It receives the NIF module.

Link to this function

target(config \\ target_config())

View Source

Returns the target triple for download or compile and load.

This function is translating and adding more info to the system architecture returned by Elixir/Erlang to one used by Rust.

The returning string format is the following:

"nif-NIF_VERSION-ARCHITECTURE-VENDOR-OS-ABI"

Examples

iex> RustlerPrecompiled.target()
{:ok, "nif-2.16-x86_64-unknown-linux-gnu"} 

iex> RustlerPrecompiled.target()
{:ok, "nif-2.15-aarch64-apple-darwin"}