Encodes and decodes Kiwi messages as Elixir structs.
use KiwiCodec, kind: :message, :struct, or :enum defines a module for a
schema definition with the KiwiCodec.DSL macros, and mix kiwi.gen or
compile_schema!/2 generates such modules from a schema. encode/1 and
decode/3 convert their structs to and from Kiwi binaries.
Data written with a newer schema decodes when decode/3 is given that schema:
fields the modules do not define are skipped. KiwiCodec.SchemaInterpreter
works without modules, for schemas loaded at runtime.
Summary
Functions
Compiles .kiwi schema text into generated Elixir modules in memory.
Decodes a binary as the given Kiwi module.
Encodes a Kiwi struct.
Encodes a Kiwi struct to iodata.
Parses .kiwi schema text into a schema AST.
Functions
Compiles .kiwi schema text into generated Elixir modules in memory.
This is a convenience for tests and tooling. For application code, prefer the
mix kiwi.gen task so generated modules are written to source files.
Decodes a binary as the given Kiwi module.
Options:
:schema- the schema the data was written with, as aKiwiCodec.Schemaor a preparedKiwiCodec.SchemaInterpreterschema. Message fields the generated modules do not define are skipped using it. Without it they raiseKiwiCodec.DecodeError.
Encodes a Kiwi struct.
Encodes a Kiwi struct to iodata.
@spec parse_schema!(String.t()) :: KiwiCodec.Schema.t()
Parses .kiwi schema text into a schema AST.