OmniBuf.SchemaMeta (omnibuf v0.1.0)

Copy Markdown View Source

Field #0 (Tag = 0x19, WireSubMsg = 12) self-describing schema metadata.

Encodes optional type_name, fields (map<uint32, string>), and recursive children (map<uint32, SchemaMeta>).

Summary

Functions

Returns the child SchemaMeta for field_num, or nil.

Decodes the inner field stream of a SchemaMeta message.

Decodes a Field #0 SchemaMeta starting right after the 0x19 tag (i.e. at ByteLen). Enforces container depth (+1 for the Field #0 WireSubMsg, +2 per children hop).

Encodes the inner field stream of a SchemaMeta message (without outer tag or ByteLen).

Encodes a SchemaMeta struct as a complete Field #0 [0x19][ByteLen][body] iodata fragment.

Merges two SchemaMeta tables according to Spec Section 8.2

Resolves a field name from meta, falling back to "field_<N>" when absent or empty "".

Types

t()

@type t() :: %OmniBuf.SchemaMeta{
  children: %{optional(non_neg_integer()) => t()},
  fields: %{optional(non_neg_integer()) => String.t()},
  type_name: String.t()
}

Functions

child_meta(arg1, field_num)

@spec child_meta(t() | nil, non_neg_integer()) :: t() | nil

Returns the child SchemaMeta for field_num, or nil.

decode_body(bin, depth, acc)

@spec decode_body(binary(), non_neg_integer(), t()) ::
  {:ok, t()} | {:error, OmniBuf.Error.t()}

Decodes the inner field stream of a SchemaMeta message.

decode_field(bin, depth)

@spec decode_field(binary(), non_neg_integer()) ::
  {:ok, t(), binary()} | {:error, OmniBuf.Error.t()}

Decodes a Field #0 SchemaMeta starting right after the 0x19 tag (i.e. at ByteLen). Enforces container depth (+1 for the Field #0 WireSubMsg, +2 per children hop).

encode_body(schema_meta)

@spec encode_body(t()) :: iodata()

Encodes the inner field stream of a SchemaMeta message (without outer tag or ByteLen).

encode_field(meta)

@spec encode_field(t()) :: iodata()

Encodes a SchemaMeta struct as a complete Field #0 [0x19][ByteLen][body] iodata fragment.

merge(a, b)

@spec merge(t() | nil, t() | nil) :: t() | nil

Merges two SchemaMeta tables according to Spec Section 8.2:

  • Later non-empty type_name wins.
  • Later fields entries override per field number (an empty string "" clears an inherited name).
  • children maps merge recursively by field number.

resolve_field_name(arg1, field_num)

@spec resolve_field_name(t() | nil, non_neg_integer()) :: String.t()

Resolves a field name from meta, falling back to "field_<N>" when absent or empty "".