Builds and loads a Rustler NIF crate generated entirely from Rusty-Elixir.
use RustQ.Native makes the current module a native compilation unit and
imports RustQ.Meta. Public entrypoints use defnif; generated helper
functions use defrust or defrustp.
defmodule MyApp.Native do
use RustQ.Native
@spec add(integer(), integer()) :: integer()
defnif add(left, right), do: left + right
endRustQ generates the crate under the Mix build directory, compiles it with
Cargo, copies the native library into the application's priv/native
directory, and injects the NIF loader. No checked-in Rust or Cargo files are
required for this path.
Genuine native policy remains explicit. Use :otp_app, :crate, :mode,
:cargo, or :crates only when their inferred defaults are not appropriate.
Generated crates are formatted before compilation. Existing
RustQ.Meta options such as :rust_sources, :rust_packages, and
:callable_modules may be passed alongside them.
Existing and precompiled crates can use RustQ as an item generator without transferring build or loading ownership:
use RustQ.Native, build: false, load: falseRustQ.Native.items/1 then returns ABI-prepared functions, codecs, and
resource implementations for splicing into the externally-owned crate.
Summary
Functions
Returns ABI-prepared Rust items from a RustQ.Native module.
Returns ABI-prepared Rust source without crate imports or initialization.
Functions
@spec items(module()) :: [RustQ.Rust.AST.item()]
Returns ABI-prepared Rust items from a RustQ.Native module.
Returns ABI-prepared Rust source without crate imports or initialization.