TTYCast.Writer (ttycast v0.1.0)

Copy Markdown

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.

Summary

Functions

Returns a specification to start this module under a supervisor.

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

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

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

Records input according to the writer input policy.

Records only the number of input bytes.

Records a named semantic marker with application-owned metadata.

Records a terminal resize.

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

Records terminal output bytes.

Types

event()

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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

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

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

event(pid, stream, payload)

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

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

flush(pid)

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

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

input(pid, iodata)

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

Records input according to the writer input policy.

input_redacted(pid, byte_count)

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

Records only the number of input bytes.

marker(pid, name, metadata \\ %{})

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

Records a named semantic marker with application-owned metadata.

output(pid, iodata)

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

resize(pid, columns, rows)

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

Records a terminal resize.

start_link(opts)

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

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

write(pid, iodata)

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

Records terminal output bytes.