Builders for common Rustler NIF code.
RustQ.Rustler returns RustQ.Rust fragments that can be spliced into real
Rust templates or declared in rustq.exs with rust_items/2.
Use the safe helpers by default. Helpers that work with raw
rustler::wrapper::NIF_TERM are named with the nif_term_ prefix so unsafe
code stays explicit.
Summary
Functions
Builds a rustler::atoms! block.
Builds cached atom helper functions backed by OnceLock<Atom>.
Builds the rustler::init! declaration for an Elixir module.
Builds a Rustler NIF function declaration.
Builds a Rust struct deriving NifStruct for an Elixir struct module.
Builds raw NIF_TERM map/struct helpers.
Builds an options struct plus decoder function for keyword/map options.
Builds a Rustler resource struct and resource registration helpers.
Returns the ResourceArc<...> Rust type for a resource.
Builds a decoder function for a Rustler resource.
Builds resource initialization code for a Rustler module.
Builds a type alias for a resource's ResourceArc type.
Returns Rust items for a RustQ.Rustler.Schema schema.
Builds a Rust enum that decodes tagged Elixir structs.
Builds safe Term<'a> map/struct helpers.
Builds a decoder function from a Rustler map term into a Rust struct.
Builds common map/term helper functions used by generated decoders.
Functions
@spec atoms( [atom() | String.t() | {atom() | String.t(), String.t()}], keyword() ) :: RustQ.Rust.Fragment.t()
Builds a rustler::atoms! block.
@spec cached_atoms( [atom() | String.t() | {atom() | String.t(), String.t()}], keyword() ) :: [RustQ.Rust.Fragment.t()]
Builds cached atom helper functions backed by OnceLock<Atom>.
@spec init(module() | String.t()) :: RustQ.Rust.Fragment.t()
Builds the rustler::init! declaration for an Elixir module.
@spec nif( atom() | String.t(), keyword() ) :: RustQ.Rust.Function.t()
Builds a Rustler NIF function declaration.
Options include :args, :returns, :body, :vis, and :schedule.
Builds a Rust struct deriving NifStruct for an Elixir struct module.
@spec nif_term_builders(keyword()) :: [RustQ.Rust.Fragment.t()]
Builds raw NIF_TERM map/struct helpers.
These helpers generate unsafe Rust and are intended for low-level Rustler code
where raw terms are required. Prefer term_builders/1 when Term<'a> is
available.
@spec opts_decoder( atom() | String.t(), keyword() ) :: [RustQ.Rust.Fragment.t()]
Builds an options struct plus decoder function for keyword/map options.
@spec resource( atom() | String.t(), keyword() ) :: [RustQ.Rust.Fragment.t()]
Builds a Rustler resource struct and resource registration helpers.
Returns the ResourceArc<...> Rust type for a resource.
@spec resource_decoder( atom() | String.t(), keyword() ) :: RustQ.Rust.Fragment.t()
Builds a decoder function for a Rustler resource.
@spec resource_init(atom() | String.t()) :: RustQ.Rust.Fragment.t()
Builds resource initialization code for a Rustler module.
@spec resource_type( atom() | String.t(), keyword() ) :: RustQ.Rust.TypeAlias.t()
Builds a type alias for a resource's ResourceArc type.
@spec schema_items(RustQ.Rustler.Schema.t()) :: [RustQ.Rust.Fragment.t()]
Returns Rust items for a RustQ.Rustler.Schema schema.
@spec tagged_enum( atom() | String.t(), keyword() ) :: [RustQ.Rust.Fragment.t()]
Builds a Rust enum that decodes tagged Elixir structs.
@spec term_builders(keyword()) :: [RustQ.Rust.Fragment.t()]
Builds safe Term<'a> map/struct helpers.
@spec term_decoder( atom() | String.t(), keyword() ) :: [RustQ.Rust.Fragment.t()]
Builds a decoder function from a Rustler map term into a Rust struct.
@spec term_helpers(keyword()) :: [RustQ.Rust.Fragment.t()]
Builds common map/term helper functions used by generated decoders.