KiwiCodec.SchemaInterpreter.Prepared (kiwi_codec v0.7.0)

Copy Markdown View Source

Indexed Kiwi schema for repeated runtime interpretation.

Prepared schemas preserve the parsed schema definitions while adding constant- time definition, message-field, and enum-variant lookup tables. Build one with KiwiCodec.SchemaInterpreter.prepare/1 and reuse it across encode/decode calls.

Summary

Functions

Returns the definition named name, or nil.

Returns the name of the enum definition_name's variant with value, or nil.

Returns the value of the enum definition_name's variant name, or nil.

Returns the field with tag id of the message definition_name, or nil.

Indexes a schema's definitions, message fields, and enum values for decoding.

Types

t()

@opaque t()

Functions

definition(prepared, name)

@spec definition(t(), String.t()) :: KiwiCodec.Schema.definition() | nil

Returns the definition named name, or nil.

enum_name(prepared, definition_name, value)

@spec enum_name(t(), String.t(), integer()) :: String.t() | nil

Returns the name of the enum definition_name's variant with value, or nil.

enum_value(prepared, definition_name, name)

@spec enum_value(t(), String.t(), String.t()) :: integer() | nil

Returns the value of the enum definition_name's variant name, or nil.

message_field(prepared, definition_name, id)

@spec message_field(t(), String.t(), pos_integer()) ::
  KiwiCodec.Schema.Field.t() | nil

Returns the field with tag id of the message definition_name, or nil.

new(schema)

@spec new(KiwiCodec.Schema.t()) :: t()

Indexes a schema's definitions, message fields, and enum values for decoding.