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,
impl<'a, Stdout, Stderr> WaitForCompletion<'a, Stdout, Stderr, NoOutput, NoTerminate>where
Stdout: OutputStream,
Stderr: OutputStream,
Sourcepub fn with_line_output(
self,
eof_timeout: Duration,
line_parsing_options: LineParsingOptions,
options: LineOutputOptions,
) -> WaitForCompletion<'a, Stdout, Stderr, LineOutput, NoTerminate>
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.
Sourcepub fn with_raw_output(
self,
eof_timeout: Duration,
options: RawOutputOptions,
) -> WaitForCompletion<'a, Stdout, Stderr, RawOutput, NoTerminate>
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,
impl<'a, Stdout, Stderr, Output> WaitForCompletion<'a, Stdout, Stderr, Output, NoTerminate>where
Stdout: OutputStream,
Stderr: OutputStream,
Sourcepub fn or_terminate(
self,
shutdown: GracefulShutdown,
) -> WaitForCompletion<'a, Stdout, Stderr, Output, WithTerminate>
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.