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

Assembles bounded control-mode replies and lexical notifications from bytes.

Reply guards retain timestamp, command number and flags. Inside a block,
notification-looking output stays data. The parser cannot authenticate
injected matching guards: shared lanes must separately qualify commands,
hooks and subscription expansion. Notification payloads need semantic
validation before they can update a graph.

A parse error retains already completed events in `error.details.events`.
Its owner must retire the lane rather than reuse the rejected state.

# `event`

```elixir
@type event() ::
  {:reply, :ok | :error, guard_id(), [binary()]}
  | {:notification, atom(), binary()}
  | {:unknown, binary()}
```

A framed reply or lexical notification. Payloads still require semantic validation before graph updates.

# `guard_id`

```elixir
@type guard_id() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}
```

A complete tmux reply guard: timestamp, command number and flags, retained for correlation.

# `option`

```elixir
@type option() ::
  {:max_chunk_bytes
   | :max_line_bytes
   | :max_frame_bytes
   | :max_frame_lines
   | :max_events, pos_integer()}
```

A positive parser ceiling, measured in bytes, lines or emitted events as named.

# `t`

```elixir
@opaque t()
```

Immutable parser carry and bounded in-flight frame state; discard it after any parse error.

# `feed`

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

Consumes one byte chunk without performing I/O.

# `finish`

```elixir
@spec finish(t()) :: :ok | {:error, LibTmux.Error.t()}
```

Rejects a stream ending inside a line or reply block.

# `new`

```elixir
@spec new([option()]) :: t()
```

Constructs a parser with positive byte, line and event limits.

---

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