pub struct PtyIo {
pub input: InputPolicy,
pub output: OutputPolicy,
pub observer: OutputObserver,
pub size: PtySize,
}Expand description
Pseudoterminal-backed I/O mode.
The child runs attached to a real controlling terminal, so it renders output exactly as it would in an interactive shell — colors, progress bars, and tty-gated formatting are preserved. Unlike the pipe-backed modes, a PTY has a single stream: the child’s stdout and stderr are merged in emission order.
The merged stream is delivered through the observer’s stdout callbacks and, when the output policy captures either stdout or stderr, retained as the result’s stdout (the two streams are merged, so either capture flag opts into keeping the combined output). The child never writes to the result’s stderr in this mode; the only bytes that can appear there are synthetic termination diagnostics injected by the lifecycle layer (for example a note that the child was killed after a timeout or cancellation).
Fields§
§input: InputPolicyStandard input policy. Only InputPolicy::Closed and InputPolicy::Bytes are supported;
inherited stdin is rejected.
Terminal stdin cannot be half-closed,
so InputPolicy::Closed does not deliver a pipe-style EOF here:
it simply means no bytes are ever written to the child’s terminal (the child keeps reading from a live tty that stays open until the PTY is torn down),
not that the child sees stdin closed.
Likewise InputPolicy::Bytes are delivered as terminal input (as if typed) through the PTY’s line discipline,
so a reader returns on a newline rather than on the writer closing.
output: OutputPolicyCapture policy for the merged output stream. Either capture_stdout
or capture_stderr retains the combined stream (surfaced as the result’s stdout);
max_output_bytes bounds it.
observer: OutputObserverObserver callbacks for the merged output stream (delivered via stdout).
size: PtySizeWindow size advertised to the child through the PTY.
Implementations§
Source§impl PtyIo
impl PtyIo
Sourcepub fn new(observer: OutputObserver) -> Self
pub fn new(observer: OutputObserver) -> Self
Create a PTY mode that observes the merged stream through observer.
Sourcepub fn with_input(self, input: InputPolicy) -> Self
pub fn with_input(self, input: InputPolicy) -> Self
Set the stdin policy.
Sourcepub fn with_output(self, output: OutputPolicy) -> Self
pub fn with_output(self, output: OutputPolicy) -> Self
Set the capture policy for the merged output stream.