# `ToonEx.Btoon.Decode`
[🔗](https://github.com/ohhi-vn/toon_ex/blob/v1.6.0/lib/toon_ex/btoon/decode/decode.ex#L1)

BTOON decoder.

Parses the BTOON wire format back into the data model:

  * Envelope: `"BTON"` magic, version, flags, optional per-message string
    table and embedded schema, then an 8-byte-aligned body.
  * Tagged values with inline `SmallInt`, fixed-width little-endian
    integers/floats, zero-copy strings and binaries (BEAM sub-binaries).
  * `StringRef` ids resolved against the session dictionary first, then the
    per-message string table.
  * `TypedArray` and `ObjectTable` payloads materialized as lists or
    exposed as zero-copy views (`typed_arrays: :views`).
  * Schema mode: `SchemaID` followed by ordered, tagless fixed-width fields
    decoded strictly according to the (embedded or supplied) schema.

## API

    iex> {:ok, value} = Btoon.Decode.decode(<<66, 84, 79, 78, 1, 0, 0, 0, 106>>)
    iex> value
    42

# `decode`

```elixir
@spec decode(
  binary(),
  keyword()
) :: {:ok, term()} | {:error, ToonEx.Btoon.DecodeError.t()}
```

Decodes a BTOON binary.

Returns `{:ok, value}` or `{:error, ToonEx.Btoon.DecodeError.t()}`.

# `decode!`

```elixir
@spec decode!(
  binary(),
  keyword()
) :: term()
```

Decodes a BTOON binary, raising `Btoon.DecodeError` on error.

# `decode_validated`

```elixir
@spec decode_validated(binary(), ToonEx.Btoon.Decode.Options.validated()) ::
  {:ok, term()} | {:error, ToonEx.Btoon.DecodeError.t()}
```

Decodes a BTOON binary using pre-validated options.

This skips option re-validation, improving throughput for repeated decoding
with the same options. Returns `{:ok, value}` or `{:error, Btoon.DecodeError.t()}`.

# `decode_validated!`

```elixir
@spec decode_validated!(binary(), ToonEx.Btoon.Decode.Options.validated()) :: term()
```

Decodes a BTOON binary using pre-validated options, raising `Btoon.DecodeError` on error.

---

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