use std::time::Duration;
use crate::domain::{
process::StopSignal,
pty::{ProcessOutput, PtyError, PtySize, SpawnRequest},
};
pub trait OutputSink: Send + Sync + 'static {
fn send(&self, output: ProcessOutput);
}
pub trait ProcessHandle: Send {
fn write_input(&mut self, bytes: &[u8]) -> Result<(), PtyError>;
fn resize(&mut self, size: PtySize) -> Result<(), PtyError>;
fn pause(&mut self) -> Result<(), PtyError>;
fn resume(&mut self) -> Result<(), PtyError>;
fn terminate(&mut self, _signal: StopSignal, _grace: Duration) -> Result<(), PtyError> {
self.kill()
}
fn kill(&mut self) -> Result<(), PtyError>;
}
pub trait ProcessRunner {
fn spawn(
&self,
request: SpawnRequest,
sink: Box<dyn OutputSink>,
) -> Result<Box<dyn ProcessHandle>, PtyError>;
}