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

Type definitions and wrapper types for the BTOON codec.

The BTOON data model mirrors TOON: `nil`, booleans, integers, floats,
UTF-8 strings, binary blobs, arrays and objects. Elixir strings are
binaries, so two wrapper structs exist to disambiguate values that are
otherwise indistinguishable:

  * `Btoon.Binary` – a binary value (tag `0x08`) as opposed to a string
    (tag `0x07`).
  * `Btoon.TypedArray` – a contiguous, homogeneous numeric buffer (tag
    `0x0C`).
  * `Btoon.ObjectTable` – a columnar table of homogeneous numeric columns
    (tag `0x0D`).
  * `Btoon.Extension` – a registered extension value (tags `0xF0`..`0xFF`).

## Element types

Element types are named atoms (`:int8`, `:uint8`, `:int16`, `:uint16`,
`:int32`, `:uint32`, `:int64`, `:uint64`, `:float32`, `:float64`) and,
for schema fields only, `:null`, `:bool`, `:string`, `:binary`, `:array`
and `:object`. See `Btoon.ElementType`.

# `decode_opt`

```elixir
@type decode_opt() ::
  {:dictionary, ToonEx.Btoon.Dictionary.t() | nil}
  | {:schema, ToonEx.Btoon.Schema.t() | nil}
  | {:keys, :strings | :atoms | :atoms!}
  | {:typed_arrays, :lists | :views}
  | {:max_depth, pos_integer()}
```

A single decoding option.

# `decode_opts`

```elixir
@type decode_opts() :: [decode_opt()]
```

Options accepted by `Btoon.decode/2` and `Btoon.decode!/2`.

# `element_type`

```elixir
@type element_type() ::
  :int8
  | :uint8
  | :int16
  | :uint16
  | :int32
  | :uint32
  | :int64
  | :uint64
  | :float32
  | :float64
  | :null
  | :bool
  | :string
  | :binary
  | :array
  | :object
```

An element type selector atom.

# `encodable`

```elixir
@type encodable() ::
  nil
  | boolean()
  | integer()
  | float()
  | String.t()
  | ToonEx.Btoon.Binary.t()
  | ToonEx.Btoon.TypedArray.t()
  | ToonEx.Btoon.ObjectTable.t()
  | ToonEx.Btoon.Extension.t()
  | [encodable()]
  | %{optional(String.t()) =&gt; encodable()}
```

Any value that can be encoded by `Btoon`.

# `encode_opt`

```elixir
@type encode_opt() ::
  {:dictionary, ToonEx.Btoon.Dictionary.t() | nil}
  | {:string_table, :auto | :off}
  | {:schema, ToonEx.Btoon.Schema.t() | nil}
  | {:typed_arrays, boolean()}
  | {:object_tables, boolean()}
```

A single encoding option.

# `encode_opts`

```elixir
@type encode_opts() :: [encode_opt()]
```

Options accepted by `Btoon.encode/2` and `Btoon.encode!/2`.

# `primitive`

```elixir
@type primitive() ::
  nil | boolean() | integer() | float() | String.t() | ToonEx.Btoon.Binary.t()
```

A BTOON primitive value.

---

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