KiwiCodec.SchemaInterpreter (kiwi_codec v0.7.0)

Copy Markdown View Source

Interpreter for parsed Kiwi schemas without generated modules.

Prefer generated modules for application code. This interpreter is useful for tooling, inspection, and compatibility tests where schemas are loaded at runtime. For repeated calls, prepare the parsed schema once with prepare/1 to replace linear definition, message-field, and enum lookups with indexed lookups.

Summary

Functions

Builds reusable lookup indexes for repeated runtime interpretation.

Skips the value of message field field_id of definition_name at the start of binary, returning the bytes after it.

Types

Functions

decode(schema, definition_name, binary)

@spec decode(schema(), String.t(), binary()) :: map() | String.t() | integer()

encode(schema, definition_name, value)

@spec encode(schema(), String.t(), map()) :: binary()

prepare(schema)

Builds reusable lookup indexes for repeated runtime interpretation.

skip_message_field(schema, definition_name, field_id, binary)

@spec skip_message_field(schema(), String.t(), non_neg_integer(), binary()) ::
  binary()

Skips the value of message field field_id of definition_name at the start of binary, returning the bytes after it.

Used to step over fields a compiled decoder does not know, with the schema the data was written with.