Trait tokio_process::CommandExt [] [src]

pub trait CommandExt {
    fn spawn_async(&mut self, handle: &Handle) -> Result<Child>;
    fn status_async(&mut self, handle: &Handle) -> StatusAsync;
    fn output_async(&mut self, handle: &Handle) -> OutputAsync;
}

Extensions provided by this crate to the Command type in the standard library.

This crate primarily enhances the standard library's Command type with asynchronous capabilities. The currently three blocking functions in the standard library, spawn, status, and output, all have asynchronous versions through this trait.

Note that the Child type spawned is specific to this crate, and that the I/O handles created from this crate are all asynchronous as well (differing from their std counterparts).

Required Methods

Executes the command as a child process, returning a handle to it.

By default, stdin, stdout and stderr are inherited from the parent.

This method will spawn the child process synchronously and return a handle to a future-aware child process. The Child returned implements Future itself to acquire the ExitStatus of the child, and otherwise the Child has methods to acquire handles to the stdin, stdout, and stderr streams.

The handle specified to this method must be a handle to a valid event loop, and all I/O this child does will be associated with the specified event loop.

Executes a command as a child process, waiting for it to finish and collecting its exit status.

By default, stdin, stdout and stderr are inherited from the parent.

The StatusAsync future returned will resolve to the ExitStatus type in the standard library representing how the process exited. If output handles are set to a pipe then they will be immediately closed after the child is spawned.

The handle specified must be a handle to a valid event loop, and all I/O this child does will be associated with the specified event loop.

If the OutputAsync future is dropped before the future resolves, then the child will be killed, if it was spawned.

Executes the command as a child process, waiting for it to finish and collecting all of its output.

Note: this method, unlike the standard library, will unconditionally configure the stdout/stderr handles to be pipes, even if they have been previously configured. If this is not desired then the spawn_async method should be used in combination with the wait_with_output method on child.

This method will return a future representing the collection of the child process's stdout/stderr. The OutputAsync future will resolve to the Output type in the standard library, containing stdout and stderr as Vec<u8> along with an ExitStatus representing how the process exited.

The handle specified must be a handle to a valid event loop, and all I/O this child does will be associated with the specified event loop.

If the OutputAsync future is dropped before the future resolves, then the child will be killed, if it was spawned.

Implementors