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

Generates native Kiwi records: decoded values Rust code can read, change, and share without
building Elixir terms, and encode later as the sparse maps generated decoders return.

The record runtime is schema-independent. The schema only supplies a definition table, read
by the decoder and encoder, and constants naming each definition, field, and enum value for
code that works with records:

    kiwi_record_definitions::NODE_CHANGE
    kiwi_records::NodeChange::FILL_PAINTS
    kiwi_records::NodePhase::REMOVED

RustQ code that works with records names this module through `alias`, and RustQ imports the
runtime's functions, methods, and types from it, and the constants' modules:

    alias KiwiCodec.RustlerGenerator.Records

    @spec fill_paints(R.ref(Records.kiwi_record())) :: R.bool()
    defrust fill_paints(record), do: record.has(Records.NodeChange.FILL_PAINTS)

`Records.Definitions.NODE_CHANGE` names a definition, so a schema definition named
`Definitions` is reached only through its Rust path.

Decoding uses the `Decoder` methods `KiwiCodec.RustlerGenerator.Decoder` lists for records.
Unknown message fields go through `kiwi_unknown_field`; see
`KiwiCodec.RustlerGenerator.UnknownFields`.

# `kiwi_record`

```elixir
@type kiwi_record() :: term()
```

The Rust type `KiwiRecord` the module provides.

# `kiwi_record_definition`

```elixir
@type kiwi_record_definition() :: term()
```

The Rust type `KiwiRecordDefinition` the module provides.

# `kiwi_record_field`

```elixir
@type kiwi_record_field() :: term()
```

The Rust type `KiwiRecordField` the module provides.

# `kiwi_record_variant`

```elixir
@type kiwi_record_variant() :: term()
```

The Rust type `KiwiRecordVariant` the module provides.

# `kiwi_value`

```elixir
@type kiwi_value() :: term()
```

The Rust type `KiwiValue` the module provides.

# `__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.

# `fragments`

```elixir
@spec fragments([KiwiCodec.Schema.definition()], String.t()) :: [term()]
```

Returns the record runtime, and the `kiwi_records!` call declaring `definitions`' table and
constants, one row per definition.

---

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