Shared high-performance OmniBuf v0.1 field encoders and decoders used by
generated plugin code (Tier 1), Protobuf integration (Tier 2), and
declarative OmniBuf.Schema structs (Tier 3).
Summary
Functions
Decodes a WireArray field, enforcing ElementType match against elem_type
(collection header mismatch MUST return a parse error) and max nesting depth.
Decodes a single collection element or map key/value.
Decodes a WireMap field, merging entries into existing (duplicate keys replace
prior values outright) and enforcing KeyType/ValueType match and depth limits.
Decodes a length-prefixed WireSubMsg into mod, merging onto existing if non-nil.
Default zero value for a schema field type.
Encodes a WireArray value ([ByteLen][ElementType: 1B][Count][Elements]).
Encodes a value for inclusion inside a WireArray or WireMap (no field tag).
Encodes a WireMap value ([ByteLen][KeyType: 1B][ValueType: 1B][Count][Entries])
with deterministic key ordering (unsigned UTF-8 byte order for strings, numeric order
for integers, false before true for booleans).
Maps an OmniBuf schema type descriptor to its wire type code (for tags/headers).
Functions
@spec decode_array(binary(), term(), non_neg_integer()) :: {:ok, list(), binary()} | {:error, OmniBuf.Error.t()}
Decodes a WireArray field, enforcing ElementType match against elem_type
(collection header mismatch MUST return a parse error) and max nesting depth.
@spec decode_element(term(), binary(), non_neg_integer()) :: {:ok, term(), binary()} | {:error, OmniBuf.Error.t()}
Decodes a single collection element or map key/value.
@spec decode_map(binary(), term(), term(), map(), non_neg_integer()) :: {:ok, map(), binary()} | {:error, OmniBuf.Error.t()}
Decodes a WireMap field, merging entries into existing (duplicate keys replace
prior values outright) and enforcing KeyType/ValueType match and depth limits.
@spec decode_submsg(module(), binary(), struct() | nil, non_neg_integer()) :: {:ok, struct(), binary()} | {:error, OmniBuf.Error.t()}
Decodes a length-prefixed WireSubMsg into mod, merging onto existing if non-nil.
Default zero value for a schema field type.
Encodes a WireArray value ([ByteLen][ElementType: 1B][Count][Elements]).
Encodes a value for inclusion inside a WireArray or WireMap (no field tag).
Encodes a WireMap value ([ByteLen][KeyType: 1B][ValueType: 1B][Count][Entries])
with deterministic key ordering (unsigned UTF-8 byte order for strings, numeric order
for integers, false before true for booleans).
@spec wire_type_for(term()) :: 0..15
Maps an OmniBuf schema type descriptor to its wire type code (for tags/headers).