KiwiCodec.RustlerGenerator.Records (kiwi_codec v0.7.0)

Copy Markdown View Source

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.

Summary

Types

The Rust type KiwiRecord the module provides.

The Rust type KiwiRecordDefinition the module provides.

The Rust type KiwiRecordField the module provides.

The Rust type KiwiRecordVariant the module provides.

The Rust type KiwiValue the module provides.

Functions

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

The RustQ AST of each defrust definition.

Callable metadata for the module's definitions.

The Rust items the module generates, in order.

The module's defrustmacro definitions.

The macro_rules! items defrustmacro emits.

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

The Rust source the module generates.

The RustQ AST of each declared Rust type.

The Rust items the module's types generate.

The Rust types the module's @types declare.

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

Types

kiwi_record()

@type kiwi_record() :: term()

The Rust type KiwiRecord the module provides.

kiwi_record_definition()

@type kiwi_record_definition() :: term()

The Rust type KiwiRecordDefinition the module provides.

kiwi_record_field()

@type kiwi_record_field() :: term()

The Rust type KiwiRecordField the module provides.

kiwi_record_variant()

@type kiwi_record_variant() :: term()

The Rust type KiwiRecordVariant the module provides.

kiwi_value()

@type kiwi_value() :: term()

The Rust type KiwiValue the module provides.

Functions

__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 defrustmods 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 @types declare.

fragments(definitions, module_prefix)

@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.