# `KiwiCodec.RustlerGenerator.Sparse.Helpers`
[🔗](https://github.com/open-pencil/kiwi_codec/blob/v0.7.0/codegen/kiwi_codec/rustler_generator/sparse/helpers.ex#L2)

Sparse decoders: a struct or message decodes as a map of the fields present, keyed by their
atoms, with `__kiwi_module__` naming its generated Elixir module.

`kiwi_sparse_struct_decoder!` defines a struct's decoder. A message's comes from
`KiwiCodec.RustlerGenerator.Sparse.Messages`, or with skip decoders from
`KiwiCodec.RustlerGenerator.Sparse.SkipMessages`; enums use
`KiwiCodec.RustlerGenerator.Values`' `kiwi_enum_decoder!`.

# `kiwi_sparse_field`

```elixir
@type kiwi_sparse_field() :: %{
  id: RustQ.Type.u32(),
  name: RustQ.Type.raw(:&quot;&amp;'static str&quot;),
  repeated: RustQ.Type.bool(),
  decode: RustQ.Type.path(:KiwiDecodeFn)
}
```

The Rust `KiwiSparseField`: a field's id, key, and how to decode its value.

# `__mix_recompile__?`

Whether the module's Rust file appeared or went since the module compiled.

# `__rustq_asts__`

The RustQ AST of each `defrust` definition.

# `__rustq_callables__`

Callable metadata for the module's definitions.

# `__rustq_items__`

The Rust items the module generates, in order.

# `__rustq_macro_definitions__`

The module's `defrustmacro` definitions.

# `__rustq_macro_items__`

The `macro_rules!` items `defrustmacro` emits.

# `__rustq_rust_modules__`

The Rust modules the module's `defrustmod`s map its aliases, or itself (`[]`), to.

# `__rustq_source__`

The Rust source the module generates.

# `__rustq_type_asts__`

The RustQ AST of each declared Rust type.

# `__rustq_type_items__`

The Rust items the module's types generate.

# `__rustq_types__`

The Rust types the module's `@type`s declare.

# `kiwi_sparse_message_fields`

```elixir
@spec kiwi_sparse_message_fields(
  RustQ.Type.path(:Env, RustQ.Type.lifetime(:a)),
  RustQ.Type.mut_ref(RustQ.Type.path(:Decoder, RustQ.Type.lifetime(:_))),
  RustQ.Type.raw(:&quot;&amp;'static str&quot;),
  RustQ.Type.str(),
  RustQ.Type.slice(kiwi_sparse_field())
) :: RustQ.Type.nif_result(term())
```

A Rust function `defrust` generates. It runs only as Rust; calling it from Elixir
raises.

# `kiwi_sparse_message_fields_remaining`

```elixir
@spec kiwi_sparse_message_fields_remaining(
  RustQ.Type.path(:Env, RustQ.Type.lifetime(:a)),
  RustQ.Type.mut_ref(RustQ.Type.path(:Decoder, RustQ.Type.lifetime(:_))),
  RustQ.Type.str(),
  RustQ.Type.slice(kiwi_sparse_field()),
  RustQ.Type.mut_ref(RustQ.Type.vec(term())),
  RustQ.Type.mut_ref(RustQ.Type.vec(term()))
) :: RustQ.Type.nif_result(RustQ.Type.unit())
```

A Rust function `defrust` generates. It runs only as Rust; calling it from Elixir
raises.

# `kiwi_sparse_module_entry`

```elixir
@spec kiwi_sparse_module_entry(
  RustQ.Type.path(:Env, RustQ.Type.lifetime(:a)),
  RustQ.Type.raw(:&quot;&amp;'static str&quot;),
  RustQ.Type.mut_ref(RustQ.Type.vec(term())),
  RustQ.Type.mut_ref(RustQ.Type.vec(term()))
) :: RustQ.Type.unit()
```

A Rust function `defrust` generates. It runs only as Rust; calling it from Elixir
raises.

# `kiwi_sparse_struct_fields`

```elixir
@spec kiwi_sparse_struct_fields(
  RustQ.Type.path(:Env, RustQ.Type.lifetime(:a)),
  RustQ.Type.mut_ref(RustQ.Type.path(:Decoder, RustQ.Type.lifetime(:_))),
  RustQ.Type.raw(:&quot;&amp;'static str&quot;),
  RustQ.Type.slice(kiwi_sparse_field())
) :: RustQ.Type.nif_result(term())
```

A Rust function `defrust` generates. It runs only as Rust; calling it from Elixir
raises.

---

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