# `RustQ.Rustler.Nif`
[🔗](https://github.com/dannote/rustq/blob/v0.11.1/lib/rustq/rustler/nif.ex#L1)

Generates Rustler NIF wrappers, stubs, `NifStruct` declarations, and raw `NIF_TERM` builders.

Most helpers in this module use RustQ AST. The raw `NIF_TERM` builders are an
explicit low-level Rustler escape boundary for unsafe wrapper APIs; prefer
`RustQ.Rustler.Term` helpers when normal `Term<'a>` values are available.

# `spec`

```elixir
@type spec() :: {atom() | String.t(), keyword()}
```

# `functions_from_source`

```elixir
@spec functions_from_source(Path.t(), [spec()], keyword()) :: [
  {atom() | String.t(), RustQ.Syn.Function.t()}
]
```

Returns selected, export-named Rust function metadata from one source file.

# `functions_from_sources`

```elixir
@spec functions_from_sources(
  [{Path.t(), [spec()]}],
  keyword()
) :: [{atom() | String.t(), RustQ.Syn.Function.t()}]
```

Returns selected, export-named Rust function metadata from multiple source groups.

# `init`

```elixir
@spec init(module() | String.t()) :: RustQ.Rust.AST.MacroItemCall.t()
```

Builds the `rustler::init!` declaration for an Elixir module.

# `raw_term_builders`

```elixir
@spec raw_term_builders(keyword()) :: [RustQ.Rust.Fragment.t()]
```

Builds unsafe raw `NIF_TERM` map and struct helpers.

# `struct`

```elixir
@spec struct(atom() | String.t(), module() | String.t(), keyword()) ::
  RustQ.Rust.AST.Struct.t()
```

Builds a Rust struct deriving `NifStruct` for an Elixir struct module.

# `stubs_from_functions`

```elixir
@spec stubs_from_functions(
  [RustQ.Syn.Function.t() | RustQ.Rust.AST.Function.t() | {term(), term()}],
  module()
) :: String.t()
```

Builds an Elixir stub module from mixed `RustQ.Syn.Function` and RustQ AST metadata.

# `stubs_from_source`

```elixir
@spec stubs_from_source(Path.t(), [spec()], module(), keyword()) :: String.t()
```

Builds an Elixir NIF-not-loaded stub module from one Rust source file.

# `stubs_from_sources`

```elixir
@spec stubs_from_sources([{Path.t(), [spec()]}], module(), keyword()) :: String.t()
```

Builds one Elixir NIF-not-loaded stub module from multiple Rust source groups.

# `wrapper`

```elixir
@spec wrapper(
  atom() | String.t(),
  keyword()
) :: RustQ.Rust.AST.Function.t()
```

Builds one NIF wrapper that delegates to an implementation function.

# `wrappers`

```elixir
@spec wrappers([spec()]) :: [RustQ.Rust.AST.Function.t()]
```

Builds NIF wrappers from explicit export specifications.

# `wrappers_from_source`

```elixir
@spec wrappers_from_source(Path.t(), [spec()], keyword()) :: [
  RustQ.Rust.AST.Function.t()
]
```

Builds NIF wrappers whose signatures are derived from Rust functions in one source file.

# `wrappers_from_sources`

```elixir
@spec wrappers_from_sources(
  [{Path.t(), [spec()]}],
  keyword()
) :: [RustQ.Rust.AST.Function.t()]
```

Builds NIF wrappers from multiple `{source_path, specs}` groups.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
