KiwiCodec (kiwi_codec v0.1.0)

Copy Markdown View Source

Pure Elixir codec for Kiwi schema binary messages.

Kiwi is a compact schema-driven format with message, struct, enum, and primitive encodings that differ from Protocol Buffers. This package is intentionally generic; product-specific schemas can live in companion packages.

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

compile_schema!(text, opts)

@spec compile_schema!(
  String.t(),
  keyword()
) :: [module()]

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.

decode(binary, module)

@spec decode(binary(), module()) :: struct()

Decodes a binary as the given Kiwi module.

encode(struct)

@spec encode(struct()) :: binary()

Encodes a Kiwi struct.

encode_to_iodata(struct)

@spec encode_to_iodata(struct()) :: iodata()

Encodes a Kiwi struct to iodata.

parse_schema!(text)

@spec parse_schema!(String.t()) :: KiwiCodec.Schema.t()

Parses .kiwi schema text into a schema AST.