Skip to main content

ProcessResult

Struct ProcessResult 

Source
#[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: String

Captured standard output as a string.

§stdout_bytes: Vec<u8>

Captured standard output as raw bytes before lossy UTF-8 conversion.

§stderr: String

Captured standard error as a string.

§stderr_bytes: Vec<u8>

Captured standard error as raw bytes before lossy UTF-8 conversion.

§stdout_truncated: bool

Whether stdout exceeded the configured capture limit.

§stderr_truncated: bool

Whether stderr exceeded the configured capture limit.

§duration: Duration

Total duration the process ran.

§timed_out: bool

Whether the process was killed due to timeout.

§cancelled: bool

Whether the process was cancelled by the caller.

Implementations§

Source§

impl ProcessResult

Source

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.

Source

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());
Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProcessResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more