use std::time::Duration;
use super::{
output_collector::collect_output,
output_reader::OutputReader,
stdin_writer::StdinWriter,
};
use crate::{
CommandError,
CommandOutput,
};
pub(crate) struct CommandIo {
stdout_reader: OutputReader,
stderr_reader: OutputReader,
stdin_writer: StdinWriter,
}
impl CommandIo {
pub(crate) fn new(
stdout_reader: OutputReader,
stderr_reader: OutputReader,
stdin_writer: StdinWriter,
) -> Self {
Self {
stdout_reader,
stderr_reader,
stdin_writer,
}
}
pub(crate) fn collect(
self,
command: &str,
status: std::process::ExitStatus,
elapsed: Duration,
) -> Result<CommandOutput, CommandError> {
collect_output(
command,
status,
elapsed,
self.stdout_reader,
self.stderr_reader,
self.stdin_writer,
)
}
}