Skip to main content

ConnInterface

Trait ConnInterface 

Source
pub trait ConnInterface: Send + Sync {
    // Required methods
    fn start(&mut self) -> Result<()>;
    fn wait(&mut self) -> Result<i32>;
    fn kill(&self) -> Result<()>;
    fn kill_graceful(&self, timeout_ms: u64) -> Result<()>;
    fn exit_code(&self) -> i32;
    fn write_data(&self, data: &[u8]) -> Result<usize>;
    fn read_data(&self, buf: &mut [u8]) -> Result<usize>;
    fn set_size(&self, rows: i64, cols: i64) -> Result<()>;
    fn close(&self) -> Result<()>;
}
Expand description

Abstraction over a PTY-connected process. Port of Go’s shellexec.ConnInterface which embeds pty.Pty.

The only implementation is MockConn (testing). The production shell path (blockcontroller/shell/lifecycle.rs) opens its PTY directly via portable_pty; it uses this trait only when a test installs a conn_factory.

Required Methods§

Source

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

Start the process. Called once after creation.

Source

fn wait(&mut self) -> Result<i32>

Wait for process to exit. Returns exit status as error.

Source

fn kill(&self) -> Result<()>

Kill the process immediately.

Source

fn kill_graceful(&self, timeout_ms: u64) -> Result<()>

Kill the process gracefully with a timeout.

Source

fn exit_code(&self) -> i32

Get the process exit code (only valid after wait returns).

Source

fn write_data(&self, data: &[u8]) -> Result<usize>

Write data to process stdin/PTY.

Source

fn read_data(&self, buf: &mut [u8]) -> Result<usize>

Read data from process stdout/PTY.

Source

fn set_size(&self, rows: i64, cols: i64) -> Result<()>

Resize the PTY.

Source

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

Close the connection.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§