pub struct CommandOutput { /* private fields */ }Expand description
Captured output and status information from a finished command.
CommandOutput stores retained raw stdout and stderr bytes. When the runner
is configured with per-stream capture limits, the retained bytes may be a
prefix of the full output; use Self::stdout_truncated and
Self::stderr_truncated to detect that case. By default, Self::stdout
and Self::stderr validate retained bytes as UTF-8 and return
str::Utf8Error for invalid output. If the command was run with
CommandRunner::lossy_output enabled,
the runner also stores lossy UTF-8 text where invalid byte sequences are
replaced with the Unicode replacement character.
§Author
Haixing Hu
Implementations§
Source§impl CommandOutput
impl CommandOutput
Sourcepub fn exit_code(&self) -> Option<i32>
pub fn exit_code(&self) -> Option<i32>
Returns the command exit code.
§Returns
Some(code) when the platform reports a numeric process exit code, or
None when the process ended in a way that does not map to a numeric
code.
Sourcepub const fn exit_status(&self) -> &ExitStatus
pub const fn exit_status(&self) -> &ExitStatus
Returns the full process exit status.
§Returns
Platform-specific process exit status reported by the operating system.
Sourcepub fn termination_signal(&self) -> Option<i32>
pub fn termination_signal(&self) -> Option<i32>
Returns the signal that terminated the process on Unix platforms.
§Returns
Some(signal) when the process was terminated by a signal, otherwise
None.
Sourcepub fn stdout(&self) -> Result<&str, Utf8Error>
pub fn stdout(&self) -> Result<&str, Utf8Error>
Returns captured standard output as UTF-8 text.
§Returns
Ok(&str) when stdout is valid UTF-8. If the command runner used lossy
output mode, this returns the stored lossy text even when the original
bytes were not valid UTF-8.
§Errors
Returns str::Utf8Error when stdout contains invalid UTF-8 and the
command runner did not enable lossy output mode.
Sourcepub fn stderr(&self) -> Result<&str, Utf8Error>
pub fn stderr(&self) -> Result<&str, Utf8Error>
Returns captured standard error as UTF-8 text.
§Returns
Ok(&str) when stderr is valid UTF-8. If the command runner used lossy
output mode, this returns the stored lossy text even when the original
bytes were not valid UTF-8.
§Errors
Returns str::Utf8Error when stderr contains invalid UTF-8 and the
command runner did not enable lossy output mode.
Sourcepub const fn elapsed(&self) -> Duration
pub const fn elapsed(&self) -> Duration
Returns the observed command duration.
§Returns
Duration from process spawn to observed termination.
Sourcepub fn stdout_bytes(&self) -> &[u8] ⓘ
pub fn stdout_bytes(&self) -> &[u8] ⓘ
Returns the captured standard output bytes.
§Returns
A borrowed slice containing stdout exactly as emitted by the process.
Sourcepub fn stderr_bytes(&self) -> &[u8] ⓘ
pub fn stderr_bytes(&self) -> &[u8] ⓘ
Returns the captured standard error bytes.
§Returns
A borrowed slice containing stderr exactly as emitted by the process.
Sourcepub const fn stdout_truncated(&self) -> bool
pub const fn stdout_truncated(&self) -> bool
Returns whether captured stdout was truncated by a configured limit.
§Returns
true when stdout emitted more bytes than the runner retained.
Sourcepub const fn stderr_truncated(&self) -> bool
pub const fn stderr_truncated(&self) -> bool
Returns whether captured stderr was truncated by a configured limit.
§Returns
true when stderr emitted more bytes than the runner retained.
Trait Implementations§
Source§impl Clone for CommandOutput
impl Clone for CommandOutput
Source§fn clone(&self) -> CommandOutput
fn clone(&self) -> CommandOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommandOutput
impl Debug for CommandOutput
Source§impl PartialEq for CommandOutput
impl PartialEq for CommandOutput
impl Eq for CommandOutput
impl StructuralPartialEq for CommandOutput
Auto Trait Implementations§
impl Freeze for CommandOutput
impl RefUnwindSafe for CommandOutput
impl Send for CommandOutput
impl Sync for CommandOutput
impl Unpin for CommandOutput
impl UnsafeUnpin for CommandOutput
impl UnwindSafe for CommandOutput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.