# `OmniBuf`
[🔗](https://github.com/omnibuf/omnibuf-elixir/blob/v0.1.0/lib/omnibuf.ex#L1)

OmniBuf v0.1 binary wire format for Elixir.

Supports all four OmniBuf implementation tiers:
- **Tier 1 (Plugin):** `protoc-gen-omnibuf-elixir` generated structs, iodata codecs,
  and lazy `Opaque` zero-decode views with in-place iodata wire splicing.
- **Tier 2 (Protobuf):** `OmniBuf.Protobuf` direct serialization/deserialization of
  standard `elixir-protobuf` (`use Protobuf`) message structs.
- **Tier 3 (Declarative Schema):** `use OmniBuf.Schema` compile-time struct DSL.
- **Tier 4 (Blind):** `OmniBuf.Blind.decode/1` and `OmniBuf.Blind.decode_json/1` for
  schema-less inspection with Field #0 `SchemaMeta` name resolution.

# `decode`

```elixir
@spec decode(binary(), module()) :: {:ok, struct()} | {:error, OmniBuf.Error.t()}
```

Decodes an OmniBuf binary into a fresh struct of `mod` (replace mode).

# `decode_blind`

```elixir
@spec decode_blind(binary(), keyword()) :: {:ok, map()} | {:error, OmniBuf.Error.t()}
```

Decodes an OmniBuf binary without a schema (Tier 4).

# `decode_blind_json`

```elixir
@spec decode_blind_json(binary(), keyword()) ::
  {:ok, String.t()} | {:error, OmniBuf.Error.t()}
```

Decodes an OmniBuf binary without a schema and serializes to JSON (Tier 4).

# `decode_proto`

```elixir
@spec decode_proto(binary(), module()) ::
  {:ok, struct()} | {:error, OmniBuf.Error.t()}
```

Decodes OmniBuf wire bytes into a standard `elixir-protobuf` struct (Tier 2).

# `encode`

```elixir
@spec encode(struct(), keyword()) :: binary()
```

Encodes an `OmniBuf.Schema` or generated Tier 1 struct to an OmniBuf binary.

# `encode_iodata`

```elixir
@spec encode_iodata(struct(), keyword()) :: iodata()
```

Encodes an `OmniBuf.Schema` or generated Tier 1 struct to iodata.

# `encode_proto`

```elixir
@spec encode_proto(struct(), keyword()) :: binary()
```

Encodes a standard `elixir-protobuf` struct into OmniBuf wire bytes (Tier 2).

# `merge`

```elixir
@spec merge(struct(), binary()) :: {:ok, struct()} | {:error, OmniBuf.Error.t()}
```

Merges an OmniBuf binary onto an existing struct (merge mode).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
