Skip to main content

MasterPty

Trait MasterPty 

Source
pub trait MasterPty: Downcast + Send {
    // Required methods
    fn resize(&self, size: PtySize) -> Result<()>;
    fn get_size(&self) -> Result<PtySize>;
    fn try_clone_reader(&self) -> Result<Box<dyn Read + Send>>;
    fn take_writer(&self) -> Result<Box<dyn Write + Send>>;

    // Provided methods
    fn process_group_leader(&self) -> Option<i32> { ... }
    fn as_raw_fd(&self) -> Option<i32> { ... }
    fn tty_name(&self) -> Option<PathBuf> { ... }
}
Expand description

Represents the master/control end of the pty.

All methods on this trait are cross-platform. Platform-specific extensions are available via MasterPtyExt (unix only).

Required Methods§

Source

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

Inform the kernel and thus the child process that the window resized.

Source

fn get_size(&self) -> Result<PtySize>

Retrieves the size of the pty as known by the kernel.

Source

fn try_clone_reader(&self) -> Result<Box<dyn Read + Send>>

Obtain a readable handle; output from the slave(s) is readable via this stream.

Source

fn take_writer(&self) -> Result<Box<dyn Write + Send>>

Obtain a writable handle; writing to it will send data to the slave end. Dropping the writer will send EOF to the slave end. It is invalid to take the writer more than once.

Provided Methods§

Source

fn process_group_leader(&self) -> Option<i32>

If applicable, return the local process id of the process group or session leader. Returns None on non-Unix platforms.

Source

fn as_raw_fd(&self) -> Option<i32>

If applicable, return the raw file descriptor of the master pty. Returns None on non-Unix platforms.

Source

fn tty_name(&self) -> Option<PathBuf>

Returns the TTY device name (e.g., /dev/pts/0). Returns None on non-Unix platforms.

Implementations§

Source§

impl dyn MasterPty

Source

pub fn is<__T: MasterPty>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

Source

pub fn downcast<__T: MasterPty>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

Source

pub fn downcast_rc<__T: MasterPty>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

Source

pub fn downcast_ref<__T: MasterPty>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

Source

pub fn downcast_mut<__T: MasterPty>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors§