use std::ffi::OsString;
use std::io::Read;
use std::path::PathBuf;
use std::process::Child;
pub(crate) enum CmdInput {
Bytes(Vec<u8>),
Reader(Box<dyn Read + Send>),
}
impl std::fmt::Debug for CmdInput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CmdInput::Bytes(bytes) => f
.debug_tuple("Bytes")
.field(&format!("{} bytes", bytes.len()))
.finish(),
CmdInput::Reader(_) => f.debug_tuple("Reader").field(&"<reader>").finish(),
}
}
}
#[derive(Debug)]
pub struct Cmd {
pub(crate) program: OsString,
pub(crate) args: Vec<OsString>,
pub(crate) envs: Vec<(OsString, OsString)>,
pub(crate) current_dir: Option<PathBuf>,
pub(crate) suppress_echo: bool,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) enum PipeMode {
Stdout,
Stderr,
Both,
}
pub struct PipelineHandle {
pub(crate) children: Vec<Child>,
}
pub struct PipelineSpawn {
pub handle: PipelineHandle,
pub stdin: Option<std::process::ChildStdin>,
pub stdout: Option<std::process::ChildStdout>,
pub stderr: Option<std::process::ChildStderr>,
}
#[derive(Debug)]
pub struct Pipeline {
pub(crate) connections: Vec<(Cmd, PipeMode)>,
pub(crate) input: Option<CmdInput>,
pub(crate) suppress_echo: bool,
}