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>
where O: OutputLike + Send + Sync + 'static,

source

pub fn into_output(self) -> O

Get the OutputLike data contained in this context object.

source

pub fn output(&self) -> &O

Get a reference to the OutputLike data contained in this context object.

source

pub fn status(&self) -> ExitStatus

Get the command’s ExitStatus.

source

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.

source

pub fn into_command(self) -> Box<dyn CommandDisplay>

Get the command contained in this context object, for use in error messages or diagnostics.

source

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.

source

pub fn error_msg<E>(self, message: E) -> Error
where E: Debug + Display + Send + Sync + 'static,

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.

Auto Trait Implementations§

§

impl<O> Freeze for OutputContext<O>
where O: Freeze,

§

impl<O> !RefUnwindSafe for OutputContext<O>

§

impl<O> Send for OutputContext<O>
where O: Send,

§

impl<O> Sync for OutputContext<O>
where O: Sync,

§

impl<O> Unpin for OutputContext<O>
where O: Unpin,

§

impl<O> !UnwindSafe for OutputContext<O>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.