pub struct OutputContext<O> { /* private fields */ }Expand description
Output combined with context about the Command that produced it.
This contains additional information about the command that was run (via a CommandDisplay
object) and can be used to construct error messages (for use in methods like
CommandExt::output_checked_as).
Note that because ExitStatus has a trivial implementation for OutputLike (where
stdout and stderr return empty strings), this
is also used as context for status calls.
Implementations§
Source§impl<O> OutputContext<O>
impl<O> OutputContext<O>
Sourcepub fn new(output: O, command: Box<dyn CommandDisplay + Send + Sync>) -> Self
pub fn new(output: O, command: Box<dyn CommandDisplay + Send + Sync>) -> Self
Construct a new OutputContext.
Sourcepub fn into_output(self) -> O
pub fn into_output(self) -> O
Get the OutputLike data contained in this context object.
Sourcepub fn output(&self) -> &O
pub fn output(&self) -> &O
Get a reference to the OutputLike data contained in this context object.
Sourcepub fn status(&self) -> ExitStatus
pub fn status(&self) -> ExitStatus
Get the command’s ExitStatus.
Sourcepub fn command(&self) -> &(dyn CommandDisplay + Send + Sync)
pub fn command(&self) -> &(dyn CommandDisplay + Send + Sync)
Get a reference to the command contained in this context object, for use in error messages or diagnostics.
Sourcepub fn into_command(self) -> Box<dyn CommandDisplay>
pub fn into_command(self) -> Box<dyn CommandDisplay>
Get the command contained in this context object, for use in error messages or diagnostics.
Sourcepub fn into_output_and_command(self) -> (O, Box<dyn CommandDisplay>)
pub fn into_output_and_command(self) -> (O, Box<dyn CommandDisplay>)
Get the output and command contained in this context object.
Unlike OutputContext::into_output and OutputContext::into_command, this lets you
extract both fields.
Sourcepub fn error(self) -> Error
pub fn error(self) -> Error
Construct an error that indicates this command failed, containing information about the command and its output.
See CommandExt for examples of the error format.
This is a thin wrapper around OutputContext::output_error.
Sourcepub fn output_error(self) -> OutputError
pub fn output_error(self) -> OutputError
Construct an error that indicates this command failed, containing information about the command and its output.
This is like OutputContext::error, but it returns the inner OutputError directly,
rather than wrapping it in an Error.
Sourcepub fn error_msg<E>(self, message: E) -> Error
pub fn error_msg<E>(self, message: E) -> Error
Construct an error that indicates this command failed, containing information about the command, its output, and the provided error message.
See CommandExt::output_checked_as for examples of the error format.