pub trait CommandExt {
// Required methods
fn spawn_async_with_handle(&mut self, handle: &Handle) -> Result<Child>;
fn status_async_with_handle(
&mut self,
handle: &Handle,
) -> Result<StatusAsync>;
fn output_async_with_handle(&mut self, handle: &Handle) -> OutputAsync;
// Provided methods
fn spawn_async(&mut self) -> Result<Child> { ... }
fn status_async(&mut self) -> Result<StatusAsync> { ... }
fn output_async(&mut self) -> OutputAsync { ... }
}Expand description
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§
Sourcefn spawn_async_with_handle(&mut self, handle: &Handle) -> Result<Child>
fn spawn_async_with_handle(&mut self, handle: &Handle) -> Result<Child>
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.
Sourcefn status_async_with_handle(&mut self, handle: &Handle) -> Result<StatusAsync>
fn status_async_with_handle(&mut self, handle: &Handle) -> Result<StatusAsync>
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
any input/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 StatusAsync future is dropped before the future resolves, then
the child will be killed, if it was spawned.
§Errors
This function will return an error immediately if the child process
cannot be spawned. Otherwise errors obtained while waiting for the child
are returned through the StatusAsync future.
Sourcefn output_async_with_handle(&mut self, handle: &Handle) -> OutputAsync
fn output_async_with_handle(&mut self, handle: &Handle) -> OutputAsync
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_asyncmethod should be used in combination with thewait_with_outputmethod 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.
Provided Methods§
Sourcefn spawn_async(&mut self) -> Result<Child>
fn spawn_async(&mut self) -> Result<Child>
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.
All I/O this child does will be associated with the current default event loop.
Sourcefn status_async(&mut self) -> Result<StatusAsync>
fn status_async(&mut self) -> Result<StatusAsync>
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
any input/output handles are set to a pipe then they will be immediately
closed after the child is spawned.
All I/O this child does will be associated with the current default event loop.
If the StatusAsync future is dropped before the future resolves, then
the child will be killed, if it was spawned.
§Errors
This function will return an error immediately if the child process
cannot be spawned. Otherwise errors obtained while waiting for the child
are returned through the StatusAsync future.
Sourcefn output_async(&mut self) -> OutputAsync
fn output_async(&mut self) -> OutputAsync
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_asyncmethod should be used in combination with thewait_with_outputmethod 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.
All I/O this child does will be associated with the current default event loop.
If the OutputAsync future is dropped before the future resolves, then
the child will be killed, if it was spawned.