use std::{
io::Result,
process::{Child, ExitStatus, Output},
};
use super::GroupChild;
#[derive(Debug)]
pub enum ErasedChild {
Grouped(GroupChild),
Ungrouped(Child),
}
impl ErasedChild {
pub fn id(&mut self) -> u32 {
match self {
Self::Grouped(c) => c.id(),
Self::Ungrouped(c) => c.id(),
}
}
pub fn kill(&mut self) -> Result<()> {
match self {
Self::Grouped(c) => c.kill(),
Self::Ungrouped(c) => c.kill(),
}
}
pub fn try_wait(&mut self) -> Result<Option<ExitStatus>> {
match self {
Self::Grouped(c) => c.try_wait(),
Self::Ungrouped(c) => c.try_wait(),
}
}
pub fn wait(&mut self) -> Result<ExitStatus> {
match self {
Self::Grouped(c) => c.wait(),
Self::Ungrouped(c) => c.wait(),
}
}
pub fn wait_with_output(self) -> Result<Output> {
match self {
Self::Grouped(c) => c.wait_with_output(),
Self::Ungrouped(c) => c.wait_with_output(),
}
}
#[cfg(unix)]
pub fn signal(&self, sig: crate::Signal) -> Result<()> {
use crate::UnixChildExt;
match self {
Self::Grouped(c) => c.signal(sig),
Self::Ungrouped(c) => c.signal(sig),
}
}
}