Trait process_control::ChildExt[][src]

pub trait ChildExt<'a>: Sealed {
    type ExitStatusControl: 'a + Control<Result = ExitStatus>;
    type OutputControl: Control<Result = Output>;
    type ExitStatusTimeout: 'a + Timeout<Result = ExitStatus>;
    type OutputTimeout: Timeout<Result = Output>;
    fn terminator(&self) -> Result<Terminator>;
fn controlled(&'a mut self) -> Self::ExitStatusControl;
fn controlled_with_output(self) -> Self::OutputControl;
fn with_timeout(
        &'a mut self,
        time_limit: Duration
    ) -> Self::ExitStatusTimeout;
fn with_output_timeout(self, time_limit: Duration) -> Self::OutputTimeout; }
Expand description

Extensions to Child for easily terminating processes.

For more information, see the module-level documentation.

Associated Types

The type returned by controlled.

The type returned by controlled_with_output.

👎 Deprecated:

use ExitStatusControl instead

The type returned by with_timeout.

👎 Deprecated:

use OutputControl instead

The type returned by with_output_timeout.

Required methods

Creates an instance of Terminator for this process.

Examples
use std::process::Command;

use process_control::ChildExt;

let process = Command::new("echo").spawn()?;
let terminator = process.terminator()?;

Creates an instance of Control that yields ExitStatus for this process.

This method parallels Child::wait but allows setting limits on the process.

Examples
use std::process::Command;
use std::time::Duration;

use process_control::ChildExt;
use process_control::Control;

let exit_status = Command::new("echo")
    .spawn()?
    .controlled()
    .time_limit(Duration::from_secs(1))
    .terminate_for_timeout()
    .wait()?
    .expect("process timed out");
assert!(exit_status.success());

Creates an instance of Control that yields Output for this process.

This method parallels Child::wait_with_output but allows setting limits on the process.

Examples
use std::process::Command;
use std::time::Duration;

use process_control::ChildExt;
use process_control::Control;

let output = Command::new("echo")
    .spawn()?
    .controlled_with_output()
    .time_limit(Duration::from_secs(1))
    .terminate_for_timeout()
    .wait()?
    .expect("process timed out");
assert!(output.status.success());
👎 Deprecated:

use controlled and Control::time_limit instead

Creates an instance of Timeout that yields ExitStatus for this process.

This method parallels Child::wait when the process must finish within a time limit.

Examples
use std::process::Command;
use std::time::Duration;

use process_control::ChildExt;
use process_control::Timeout;

let exit_status = Command::new("echo")
    .spawn()?
    .with_timeout(Duration::from_secs(1))
    .terminating()
    .wait()?
    .expect("process timed out");
assert!(exit_status.success());
👎 Deprecated:

use controlled_with_output and Control::time_limit instead

Creates an instance of Timeout that yields Output for this process.

This method parallels Child::wait_with_output when the process must finish within a time limit.

Examples
use std::process::Command;
use std::time::Duration;

use process_control::ChildExt;
use process_control::Timeout;

let output = Command::new("echo")
    .spawn()?
    .with_output_timeout(Duration::from_secs(1))
    .terminating()
    .wait()?
    .expect("process timed out");
assert!(output.status.success());

Implementations on Foreign Types

👎 Deprecated:

use ExitStatusControl instead

👎 Deprecated:

use OutputControl instead

👎 Deprecated:

use controlled and Control::time_limit instead

👎 Deprecated:

use controlled_with_output and Control::time_limit instead

Implementors