pub struct ProcessResult<T> { /* private fields */ }Expand description
The captured result of running a process to completion.
T is the standard-output payload: String for the text helpers
(output_string) or Vec<u8> for the raw-bytes helper (output_bytes).
Standard error is always captured as text. A non-zero exit code is not
treated as an error on its own — inspect code or call
ensure_success.
Implementations§
Source§impl<T> ProcessResult<T>
impl<T> ProcessResult<T>
Sourcepub fn into_stdout(self) -> T
pub fn into_stdout(self) -> T
Consume the result and return just the captured standard output.
Sourcepub fn code(&self) -> Option<i32>
pub fn code(&self) -> Option<i32>
The process exit code, or None when the run yielded no code — killed by
its timeout (timed_out is then true) or terminated
by a signal on Unix (timed_out is false). There is no synthetic
sentinel: a missing code is None, never -1.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Whether the process exited with code 0.
Sourcepub fn ensure_success(self) -> Result<ProcessResult<T>, Error>where
T: StdoutText,
pub fn ensure_success(self) -> Result<ProcessResult<T>, Error>where
T: StdoutText,
Return self unchanged when the run succeeded, otherwise the matching
error: Error::Timeout if the run was killed by its deadline (checked
first), an IO error if it was killed by a signal (no exit code), else
Error::Exit for a non-zero exit, carrying the code and both
(truncated) captured streams.
Source§impl ProcessResult<String>
impl ProcessResult<String>
Sourcepub fn combined(&self) -> String
pub fn combined(&self) -> String
Standard output followed by standard error, concatenated — handy when a tool interleaves diagnostics across both streams.
Sourcepub fn diagnostic(&self) -> &str
pub fn diagnostic(&self) -> &str
The best human-facing message from a captured run: standard error if it
carries text, otherwise standard output — git/jj put CONFLICT …
and nothing to commit on stdout, so a probe that captured the result
(rather than erroring) can build the same friendly message
Error::diagnostic gives the erroring path.
Trait Implementations§
Source§impl<T> Clone for ProcessResult<T>where
T: Clone,
impl<T> Clone for ProcessResult<T>where
T: Clone,
Source§fn clone(&self) -> ProcessResult<T>
fn clone(&self) -> ProcessResult<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for ProcessResult<T>where
T: Debug,
impl<T> Debug for ProcessResult<T>where
T: Debug,
Source§impl<T> PartialEq for ProcessResult<T>where
T: PartialEq,
impl<T> PartialEq for ProcessResult<T>where
T: PartialEq,
Source§fn eq(&self, other: &ProcessResult<T>) -> bool
fn eq(&self, other: &ProcessResult<T>) -> bool
self and other values to be equal, and is used by ==.