Flatbuf.Codegen.Union (flatbuf v0.1.0)

Copy Markdown View Source

Emits an Elixir module for a FlatBuffers union declaration.

The module owns the discriminator ↔ variant mapping and the two per-direction dispatch helpers:

  • decode_variant/3 — given a discriminator integer and the referenced position in the buffer, return {variant_atom, value}.
  • build_variant/3 — given a variant atom and a value, write it into the buffer and return {builder, addr} so the calling table can add (discriminator, uoffset) as a pair of fields.

Variant 0 is always the implicit :NONE.

Summary

Functions

generate(u, schema, opts)

@spec generate(Flatbuf.Schema.Union.t(), Flatbuf.Schema.t(), keyword()) ::
  {module(), String.t()}