#[non_exhaustive]pub struct ProcessResult {
pub exit_code: Option<i32>,
pub stdout: String,
pub stdout_bytes: Vec<u8>,
pub stderr: String,
pub stderr_bytes: Vec<u8>,
pub stdout_truncated: bool,
pub stderr_truncated: bool,
pub duration: Duration,
pub timed_out: bool,
pub cancelled: bool,
}Expand description
Result of a completed subprocess execution.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.exit_code: Option<i32>Process exit code. None if the process was killed.
stdout: StringCaptured standard output as a string.
stdout_bytes: Vec<u8>Captured standard output as raw bytes before lossy UTF-8 conversion.
stderr: StringCaptured standard error as a string.
stderr_bytes: Vec<u8>Captured standard error as raw bytes before lossy UTF-8 conversion.
stdout_truncated: boolWhether stdout exceeded the configured capture limit.
stderr_truncated: boolWhether stderr exceeded the configured capture limit.
duration: DurationTotal duration the process ran.
timed_out: boolWhether the process was killed due to timeout.
cancelled: boolWhether the process was cancelled by the caller.
Implementations§
Source§impl ProcessResult
impl ProcessResult
Sourcepub fn completed(
exit_code: Option<i32>,
stdout_bytes: Vec<u8>,
stderr_bytes: Vec<u8>,
stdout_truncated: bool,
stderr_truncated: bool,
duration: Duration,
timed_out: bool,
cancelled: bool,
) -> Self
pub fn completed( exit_code: Option<i32>, stdout_bytes: Vec<u8>, stderr_bytes: Vec<u8>, stdout_truncated: bool, stderr_truncated: bool, duration: Duration, timed_out: bool, cancelled: bool, ) -> Self
Build a process result from captured output bytes.
Sourcepub fn success(&self) -> bool
pub fn success(&self) -> bool
Check if the process exited successfully (exit code 0).
§Example
use rskit_process::ProcessResult;
use std::time::Duration;
let result = ProcessResult::completed(
Some(0),
b"output".to_vec(),
Vec::new(),
false,
false,
Duration::from_secs(1),
false,
false,
);
assert!(result.success());Sourcepub fn check(&self) -> AppResult<&Self>
pub fn check(&self) -> AppResult<&Self>
Verify the process exited successfully, returning an error if not.
§Example
use rskit_process::{ProcessConfig, ProcessSpec, run_with_cancel};
use tokio_util::sync::CancellationToken;
let spec = ProcessSpec::new("echo").arg("hello");
let result = run_with_cancel(&spec, &ProcessConfig::default(), CancellationToken::new()).await?;
result.check()?;Trait Implementations§
Source§impl Clone for ProcessResult
impl Clone for ProcessResult
Source§fn clone(&self) -> ProcessResult
fn clone(&self) -> ProcessResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ProcessResult
impl RefUnwindSafe for ProcessResult
impl Send for ProcessResult
impl Sync for ProcessResult
impl Unpin for ProcessResult
impl UnsafeUnpin for ProcessResult
impl UnwindSafe for ProcessResult
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
Mutably borrows from an owned value. Read more