Skip to main content

WaitForCompletion

Struct WaitForCompletion 

Source
pub struct WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Stdout: OutputStream, Stderr: OutputStream,
{ /* private fields */ }
Expand description

Staged builder returned by ProcessHandle::wait_for_completion.

Compose one wait, optionally one output mode, and optionally graceful termination on timeout, then .await to run it. See the module-level docs for examples.

Stdin is closed before the wait begins (matching tokio::process::Child::wait) on every variant. If the wait times out without .or_terminate(...), the process keeps running; with .or_terminate(...), cleanup is forced through ProcessHandle::terminate.

Implementations§

Source§

impl<'a, Stdout, Stderr> WaitForCompletion<'a, Stdout, Stderr, NoOutput, NoTerminate>
where Stdout: OutputStream, Stderr: OutputStream,

Source

pub fn with_line_output( self, eof_timeout: Duration, line_parsing_options: LineParsingOptions, options: LineOutputOptions, ) -> WaitForCompletion<'a, Stdout, Stderr, LineOutput, NoTerminate>

Configure line-mode output collection.

Collectors are attached when this method is called. If the stream was configured with .no_replay(), output produced before attachment may be discarded; configure replay before spawning when startup output must be included.

eof_timeout bounds the additional post-exit wait for stdout / stderr consumers to observe EOF after process completion (or, when paired with .or_terminate(...), after cleanup termination). It is a single budget shared by stdout and stderr: when one stream finishes early, the surviving stream’s drain is still bounded by the original eof_timeout measured from process exit, not restarted from the first stream’s EOF. A stream still producing output once the budget is exhausted is aborted and WaitWithOutputError::OutputCollectionTimeout is returned.

Source

pub fn with_raw_output( self, eof_timeout: Duration, options: RawOutputOptions, ) -> WaitForCompletion<'a, Stdout, Stderr, RawOutput, NoTerminate>

Configure raw byte output collection.

Use this when the child’s output is not UTF-8 line-oriented (binary blobs, framed protocols, anything where line parsing would corrupt bytes). eof_timeout behaves the same as in Self::with_line_output.

Source§

impl<'a, Stdout, Stderr, Output> WaitForCompletion<'a, Stdout, Stderr, Output, NoTerminate>
where Stdout: OutputStream, Stderr: OutputStream,

Source

pub fn or_terminate( self, shutdown: GracefulShutdown, ) -> WaitForCompletion<'a, Stdout, Stderr, Output, WithTerminate>

Force graceful termination if the wait times out.

On a wait timeout (or a non-timeout wait failure), ProcessHandle::terminate runs the supplied shutdown sequence and the result is reported as WaitForCompletionOrTerminateResult::TerminatedAfterTimeout on success, or as a WaitOrTerminateError / WaitWithOutputError when termination itself fails.

Total wall-clock time can exceed the wait timeout plus the per-platform graceful budget carried by shutdown (the sum of every Unix phase timeout, or timeout on Windows) by one additional fixed 3-second wait when the force-kill fallback is required.

Trait Implementations§

Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, LineOutput, NoTerminate>
where Stdout: OutputStream + Subscribable + Send + 'a, Stderr: OutputStream + Subscribable + Send + 'a,

Source§

type Output = Result<WaitForCompletionResult<ProcessOutput<CollectedLines>>, WaitWithOutputError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, LineOutput, NoTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, LineOutput, WithTerminate>
where Stdout: OutputStream + Subscribable + Send + 'a, Stderr: OutputStream + Subscribable + Send + 'a,

Available on Unix or Windows only.
Source§

type Output = Result<WaitForCompletionOrTerminateResult<ProcessOutput<CollectedLines>>, WaitWithOutputError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, LineOutput, WithTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, NoOutput, NoTerminate>
where Stdout: OutputStream + Send + 'a, Stderr: OutputStream + Send + 'a,

Source§

type Output = Result<WaitForCompletionResult, WaitError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, NoOutput, NoTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, NoOutput, WithTerminate>
where Stdout: OutputStream + Send + 'a, Stderr: OutputStream + Send + 'a,

Available on Unix or Windows only.
Source§

type Output = Result<WaitForCompletionOrTerminateResult, WaitOrTerminateError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, NoOutput, WithTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, RawOutput, NoTerminate>
where Stdout: OutputStream + Subscribable + Send + 'a, Stderr: OutputStream + Subscribable + Send + 'a,

Source§

type Output = Result<WaitForCompletionResult<ProcessOutput<CollectedBytes>>, WaitWithOutputError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, RawOutput, NoTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl<'a, Stdout, Stderr> IntoFuture for WaitForCompletion<'a, Stdout, Stderr, RawOutput, WithTerminate>
where Stdout: OutputStream + Subscribable + Send + 'a, Stderr: OutputStream + Subscribable + Send + 'a,

Available on Unix or Windows only.
Source§

type Output = Result<WaitForCompletionOrTerminateResult<ProcessOutput<CollectedBytes>>, WaitWithOutputError>

The output that the future will produce on completion.
Source§

type IntoFuture = Pin<Box<dyn Future<Output = <WaitForCompletion<'a, Stdout, Stderr, RawOutput, WithTerminate> as IntoFuture>::Output> + Send + 'a>>

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

§

impl<'a, Stdout, Stderr, Output, Terminate> Freeze for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Output: Freeze, Terminate: Freeze,

§

impl<'a, Stdout, Stderr, Output, Terminate> !RefUnwindSafe for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>

§

impl<'a, Stdout, Stderr, Output, Terminate> Send for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Output: Send, Terminate: Send, Stdout: Send, Stderr: Send,

§

impl<'a, Stdout, Stderr, Output, Terminate> Sync for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Output: Sync, Terminate: Sync, Stdout: Sync, Stderr: Sync,

§

impl<'a, Stdout, Stderr, Output, Terminate> Unpin for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Output: Unpin, Terminate: Unpin,

§

impl<'a, Stdout, Stderr, Output, Terminate> UnsafeUnpin for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>
where Output: UnsafeUnpin, Terminate: UnsafeUnpin,

§

impl<'a, Stdout, Stderr, Output, Terminate> !UnwindSafe for WaitForCompletion<'a, Stdout, Stderr, Output, Terminate>

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> 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, 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
Source§

impl<T> Sink for T
where T: Send + 'static,