Output in std::process - Rust (original) (raw)
Struct Output
1.0.0 · Source
pub struct Output {
pub status: ExitStatus,
pub stdout: Vec<u8>,
pub stderr: Vec<u8>,
}Expand description
The status (exit code) of the process.
The data that the process wrote to stdout.
The data that the process wrote to stderr.
🔬This is a nightly-only experimental API. (exit_status_error #84908)
Returns an error if a nonzero exit status was received.
If the Command exited successfully,self is returned.
This is equivalent to calling exit_okon 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
stderrusing a custom error type. This is usually correct for libraries.
§Examples
#![feature(exit_status_error)]
use std::process::Command;
assert!(Command::new("false").output().unwrap().exit_ok().is_err());
Tests for self and other values to be equal, and is used by ==.
1.0.0§
Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of[From](../convert/trait.From.html "trait std::convert::From")<T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.