Skip to main content

PtyMaster

Trait PtyMaster 

Source
pub trait PtyMaster:
    AsyncRead
    + AsyncWrite
    + Send
    + Sync
    + Unpin {
    // Required methods
    fn resize(&self, size: WindowSize) -> Result<()>;
    fn window_size(&self) -> Result<WindowSize>;
    fn close(&mut self) -> Result<()>;
    fn is_open(&self) -> bool;
    fn as_raw_fd(&self) -> RawFd;
}
Expand description

The master side of a pseudo-terminal.

This trait represents the controller end of a PTY pair. It provides async read/write access to the terminal and methods for controlling the PTY (resizing, closing, etc.).

§Platform Behavior

  • Unix: Wraps a file descriptor for the master PTY.
  • Windows: Wraps ConPTY input/output pipes.

Required Methods§

Source

fn resize(&self, size: WindowSize) -> Result<()>

Resize the PTY to the given window size.

This sends a window size change notification to the child process (SIGWINCH on Unix, ConPTY resize on Windows).

Source

fn window_size(&self) -> Result<WindowSize>

Get the current window size.

Source

fn close(&mut self) -> Result<()>

Close the master side of the PTY.

This signals EOF to the child process. After calling this method, reads will return EOF and writes will fail.

Source

fn is_open(&self) -> bool

Check if the PTY is still open.

Source

fn as_raw_fd(&self) -> RawFd

Get the raw file descriptor (Unix) or handle (Windows).

§Safety

The returned value is platform-specific and should only be used for low-level operations that understand the platform semantics.

Implementors§