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

Lazy zero-decode `Opaque` packet views and in-place iodata wire splicing.

Unchanged fields are never decoded and are preserved as zero-copy sub-binaries
until the final `IO.iodata_to_binary/1` call.

# `extract_submsg`

```elixir
@spec extract_submsg(binary(), non_neg_integer()) ::
  {:ok, binary() | nil} | {:error, OmniBuf.Error.t()}
```

Convenience helper that extracts a single `WireSubMsg` field's raw payload bytes,
concatenating multiple occurrences if present so repeated submessages merge cleanly.

# `find_all`

```elixir
@spec find_all(binary(), non_neg_integer(), 0..15 | :bool) ::
  {:ok, [{0..15, binary()}]} | {:error, OmniBuf.Error.t()}
```

Scans `bin` in O(fields) time and returns all matching occurrences (in wire order)
of `target_field` with `target_wt`, as a list of `{wire_type, rest_after_tag}`.

# `find_last`

```elixir
@spec find_last(binary(), non_neg_integer(), 0..15 | :bool) ::
  {:ok, {:found, 0..15, binary()} | :not_found} | {:error, OmniBuf.Error.t()}
```

Scans `bin` in O(fields) time and returns the raw value binary (starting right after
the tag) of the **last** occurrence of `target_field` with `target_wt` (or either
`WireBoolFalse`/`WireBoolTrue` when `target_wt == :bool`).

Returns `{:ok, {:found, wire_type, rest_after_tag}}`, `{:ok, :not_found}`, or `{:error, err}`.

# `splice`

```elixir
@spec splice(binary(), %{optional(non_neg_integer()) =&gt; iodata()}) ::
  {:ok, binary()} | {:error, OmniBuf.Error.t()}
```

Splices `dirty` field replacements into `packet` without decoding untouched fields.

`dirty` is a map `%{field_number => encoded_field_iodata}` where `encoded_field_iodata`
is the full `[Tag, Value]` iodata for that field (or `[]` to omit/clear the field).

Preserves untouched byte runs as zero-copy sub-binaries, drops duplicate occurrences
of spliced fields, validates framing of skipped fields, and appends any dirty fields
not originally present in `packet` in ascending field-number order.

---

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