LibTmux.Protocol (libtmux v0.0.1-alpha.1)

Copy Markdown View Source

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.

Summary

Types

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

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

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

t()

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

Functions

Consumes one byte chunk without performing I/O.

Rejects a stream ending inside a line or reply block.

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

Types

event()

@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()

@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()

@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()

@opaque t()

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

Functions

feed(state, chunk)

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

Consumes one byte chunk without performing I/O.

finish(protocol)

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

Rejects a stream ending inside a line or reply block.

new(options \\ [])

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

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