command_error/
try_wait_context.rsuse std::borrow::Borrow;
use std::fmt::Debug;
use std::process::ExitStatus;
#[cfg(doc)]
use std::process::Child;
#[cfg(doc)]
use std::process::Command;
use crate::CommandDisplay;
use crate::OutputContext;
pub struct TryWaitContext {
pub(crate) status: Option<ExitStatus>,
pub(crate) command: Box<dyn CommandDisplay + Send + Sync>,
}
impl TryWaitContext {
pub fn status(&self) -> Option<ExitStatus> {
self.status
}
pub fn command(&self) -> &(dyn CommandDisplay + Send + Sync) {
self.command.borrow()
}
pub fn into_command(self) -> Box<(dyn CommandDisplay + Send + Sync)> {
self.command
}
pub fn into_output_context(self) -> Option<OutputContext<ExitStatus>> {
self.status.map(|status| OutputContext {
output: status,
command: self.command,
})
}
}
impl Debug for TryWaitContext {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TryWaitContext")
.field("status", &self.status)
.field("command", &self.command.to_string())
.finish()
}
}