# `TTYCast.Writer`

GenServer writer for seekable, compressed terminal recordings.

Writers receive terminal events synchronously and persist chunks to disk before
replying. Use `write/2` for terminal output, `input/2` for user input subject
to the configured input policy, and `event/3` or `marker/3` for semantic host
application data.

Most callers should use `TTYCast.write/3` for scoped lifecycle management.

# `event`

```elixir
@type event() ::
  {:output, non_neg_integer(), binary()}
  | {:input, non_neg_integer(), binary()}
  | {:input_redacted, non_neg_integer(), non_neg_integer()}
  | {:resize, non_neg_integer(), pos_integer(), pos_integer()}
  | {:marker, non_neg_integer(), atom(), map()}
  | {:event, non_neg_integer(), atom(), term()}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(pid() | nil) :: :ok
```

Flushes, writes the final trailer/footer, and stops the writer.

# `event`

```elixir
@spec event(pid() | nil, atom(), term()) :: :ok
```

Records a custom semantic event on an application-owned stream.

# `flush`

```elixir
@spec flush(pid() | nil) :: :ok
```

Flushes the current in-memory event batch as a chunk.

# `input`

```elixir
@spec input(pid() | nil, IO.chardata()) :: :ok
```

Records input according to the writer input policy.

# `input_redacted`

```elixir
@spec input_redacted(pid() | nil, non_neg_integer()) :: :ok
```

Records only the number of input bytes.

# `marker`

```elixir
@spec marker(pid() | nil, atom(), map()) :: :ok
```

Records a named semantic marker with application-owned metadata.

# `output`

```elixir
@spec output(pid() | nil, IO.chardata()) :: :ok
```

# `resize`

```elixir
@spec resize(pid() | nil, pos_integer(), pos_integer()) :: :ok
```

Records a terminal resize.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Starts a writer process. Requires `:path`, `:width`, and `:height` options.

# `write`

```elixir
@spec write(pid() | nil, IO.chardata()) :: :ok
```

Records terminal output bytes.

---

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