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

Copy Markdown View Source

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.

Summary

Types

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

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

Functions

Removes one framing newline and validates the complete field value.

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

Types

field_option()

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

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

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

Functions

decode_field(response, type, options \\ [])

@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(value, options \\ [])

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

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