Struct Output

struct Output { ... }

The output of a finished process.

This is returned in a Result by either the output method of a Command, or the wait_with_output method of a Child process.

Fields

status: ExitStatus

The status (exit code) of the process.

stdout: Vec<u8>

The data that the process wrote to stdout.

stderr: Vec<u8>

The data that the process wrote to stderr.

Implementations

impl Output

fn exit_ok(self: Self) -> Result<Self, ExitStatusError>

Returns an error if a nonzero exit status was received.

If the Command exited successfully, self is returned.

This is equivalent to calling exit_ok on Output.status.

Note that this will throw away the Output::stderr field in the error case. If the child process outputs useful informantion to stderr, you can:

  • Use cmd.stderr(Stdio::inherit()) to forward the stderr child process to the parent's stderr, usually printing it to console where the user can see it. This is usually correct for command-line applications.
  • Capture stderr using a custom error type. This is usually correct for libraries.

Examples

#![feature(exit_status_error)]
# #[cfg(all(unix, not(target_os = "android"), not(all(target_vendor = "apple", not(target_os = "macos")))))] {
use std::process::Command;
assert!(Command::new("false").output().unwrap().exit_ok().is_err());
# }

impl Clone for Output

fn clone(self: &Self) -> Output

impl Debug for Output

fn fmt(self: &Self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for Output

impl Freeze for Output

impl PartialEq for Output

fn eq(self: &Self, other: &Output) -> bool

impl RefUnwindSafe for Output

impl Send for Output

impl StructuralPartialEq for Output

impl Sync for Output

impl Unpin for Output

impl UnwindSafe for Output

impl<T> Any for Output

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Output

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Output

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

impl<T> CloneToUninit for Output

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Output

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Output

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Output

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Output

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

impl<T, U> TryInto for Output

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