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. Self::stdout and
Self::stderr return raw bytes exactly as retained. Use
Self::stdout_text and Self::stderr_text for strict UTF-8 text, or
Self::stdout_lossy_text and Self::stderr_lossy_text to replace
invalid byte sequences with the Unicode replacement character.
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) -> &[u8] ⓘ
pub fn stdout(&self) -> &[u8] ⓘ
Returns captured standard output bytes.
§Returns
A borrowed slice containing stdout exactly as emitted by the process.
Sourcepub fn stderr(&self) -> &[u8] ⓘ
pub fn stderr(&self) -> &[u8] ⓘ
Returns captured standard error bytes.
§Returns
A borrowed slice containing stderr exactly as emitted by the process.
Sourcepub fn stdout_text(&self) -> Result<&str, Utf8Error>
pub fn stdout_text(&self) -> Result<&str, Utf8Error>
Returns captured standard output as strict UTF-8 text.
§Returns
Ok(&str) when stdout is valid UTF-8.
§Errors
Returns str::Utf8Error when stdout contains invalid UTF-8.
Sourcepub fn stderr_text(&self) -> Result<&str, Utf8Error>
pub fn stderr_text(&self) -> Result<&str, Utf8Error>
Returns captured standard error as strict UTF-8 text.
§Returns
Ok(&str) when stderr is valid UTF-8.
§Errors
Returns str::Utf8Error when stderr contains invalid UTF-8.
Sourcepub fn stdout_lossy_text(&self) -> Cow<'_, str>
pub fn stdout_lossy_text(&self) -> Cow<'_, str>
Returns captured standard output as UTF-8 text, replacing invalid bytes.
§Returns
Borrowed UTF-8 text when stdout is valid UTF-8, or an owned string with invalid byte sequences replaced by the Unicode replacement character.
Sourcepub fn stderr_lossy_text(&self) -> Cow<'_, str>
pub fn stderr_lossy_text(&self) -> Cow<'_, str>
Returns captured standard error as UTF-8 text, replacing invalid bytes.
§Returns
Borrowed UTF-8 text when stderr is valid UTF-8, or an owned string with invalid byte sequences replaced by the Unicode replacement character.
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 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 (const: unstable) · 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
Source§fn eq(&self, other: &CommandOutput) -> bool
fn eq(&self, other: &CommandOutput) -> bool
self and other values to be equal, and is used by ==.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.