Skip to main content

capture_pty

Function capture_pty 

Source
pub fn capture_pty(
    bin: &Path,
    args: &[&str],
    cols: u16,
    rows: u16,
    timeout: Duration,
) -> Result<(Size, Vec<CapturedFrame>)>
Expand description

Runs bin (with args) under a real pseudo-terminal sized colsxrows, and captures its settled frames until it exits or timeout elapses.

Polls the accumulated PTY output through a [vt100::Parser] every POLL_INTERVAL, diffing each poll’s [vt100::Screen] cell-by-cell against the previous one; a poll with no visible change produces no CapturedFrame, the same convention FrameRecorder uses for an empty draw_layers call.

§Errors

Returns an error if the PTY can’t be opened, bin can’t be spawned, or the reader thread panics.

§Panics

Panics if the internal output buffer’s lock is poisoned, which only happens if the reader thread itself panics while holding it.