# `LibTmux.Codec`
[🔗](https://github.com/libtmux/libtmux-elixir/blob/b72452c198917433229bdc266a68c163541b6127/lib/libtmux/codec.ex#L1)

Decodes bounded field responses and control-output bytes.

A field response contains one free-form field and one framing newline.
The default raw mode removes only its framing newline and requires a
separately qualified raw source. Use `encoding: :escaped_v1` for output
produced by `LibTmux.Format.field/1`, including tmux 3.4's print path.
This is a conservative response codec, not a multi-field row codec.

# `field_option`

```elixir
@type field_option() ::
  {:encoding, :raw | :escaped_v1}
  | {:max_bytes, pos_integer()}
  | {:min | :max, integer() | nil}
```

Field framing and value validation options; min and max apply only to integer fields.

# `field_type`

```elixir
@type field_type() :: :bytes | :string | :integer | :boolean
```

The required decoded field category; string additionally requires valid UTF-8.

# `decode_field`

```elixir
@spec decode_field(binary(), :bytes | :string, [field_option()]) ::
  {:ok, binary()} | {:error, LibTmux.Error.t()}
@spec decode_field(binary(), :integer, [field_option()]) ::
  {:ok, integer()} | {:error, LibTmux.Error.t()}
@spec decode_field(binary(), :boolean, [field_option()]) ::
  {:ok, boolean()} | {:error, LibTmux.Error.t()}
```

Removes one framing newline and validates the complete field value.

# `decode_output`

```elixir
@spec decode_output(binary(), [{:max_bytes, pos_integer()}]) ::
  {:ok, binary()} | {:error, LibTmux.Error.t()}
```

Decodes tmux's three-digit octal output escapes as bytes.

---

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