pub trait Child {
type Stdin: Stdin + IntoStdio;
type Stdout: Stdout + IntoStdio;
type Stderr: Stderr + IntoStdio;
Show 17 methods
// Required methods
fn stdin(&self) -> Option<ChildStdin<&Self::Stdin>>;
fn stdout(&self) -> Option<ChildStdout<&Self::Stdout>>;
fn stderr(&self) -> Option<ChildStderr<&Self::Stderr>>;
fn stdin_mut(&mut self) -> Option<ChildStdin<&mut Self::Stdin>>;
fn stdout_mut(&mut self) -> Option<ChildStdout<&mut Self::Stdout>>;
fn stderr_mut(&mut self) -> Option<ChildStderr<&mut Self::Stderr>>;
fn set_stdin(&mut self, stdin: Option<Self::Stdin>);
fn set_stdout(&mut self, stdout: Option<Self::Stdout>);
fn set_stderr(&mut self, stderr: Option<Self::Stderr>);
fn take_stdin(&mut self) -> Option<ChildStdin<Self::Stdin>>;
fn take_stdout(&mut self) -> Option<ChildStdout<Self::Stdout>>;
fn take_stderr(&mut self) -> Option<ChildStderr<Self::Stderr>>;
fn id(&self) -> Option<u32>;
fn kill(&mut self) -> impl Future<Output = Result<()>> + Send;
fn try_wait(&mut self) -> Result<Option<ExitStatus>>;
fn wait(&mut self) -> impl Future<Output = Result<ExitStatus>> + Send;
fn wait_with_output(self) -> impl Future<Output = Result<Output>> + Send;
}Expand description
An abstraction of a spawned child process.
Required Associated Types§
Required Methods§
Sourcefn stdin(&self) -> Option<ChildStdin<&Self::Stdin>>
fn stdin(&self) -> Option<ChildStdin<&Self::Stdin>>
Returns the stdin handle if it was configured.
Sourcefn stdout(&self) -> Option<ChildStdout<&Self::Stdout>>
fn stdout(&self) -> Option<ChildStdout<&Self::Stdout>>
Returns the stdout handle if it was configured.
Sourcefn stderr(&self) -> Option<ChildStderr<&Self::Stderr>>
fn stderr(&self) -> Option<ChildStderr<&Self::Stderr>>
Returns the stderr handle if it was configured.
Sourcefn stdin_mut(&mut self) -> Option<ChildStdin<&mut Self::Stdin>>
fn stdin_mut(&mut self) -> Option<ChildStdin<&mut Self::Stdin>>
Returns a mutable reference to the stdin handle if it was configured.
Sourcefn stdout_mut(&mut self) -> Option<ChildStdout<&mut Self::Stdout>>
fn stdout_mut(&mut self) -> Option<ChildStdout<&mut Self::Stdout>>
Returns a mutable reference to the stdout handle if it was configured.
Sourcefn stderr_mut(&mut self) -> Option<ChildStderr<&mut Self::Stderr>>
fn stderr_mut(&mut self) -> Option<ChildStderr<&mut Self::Stderr>>
Returns a mutable reference to the stderr handle if it was configured.
Sourcefn set_stdout(&mut self, stdout: Option<Self::Stdout>)
fn set_stdout(&mut self, stdout: Option<Self::Stdout>)
Sets the stdout handle.
Sourcefn set_stderr(&mut self, stderr: Option<Self::Stderr>)
fn set_stderr(&mut self, stderr: Option<Self::Stderr>)
Sets the stderr handle.
Sourcefn take_stdin(&mut self) -> Option<ChildStdin<Self::Stdin>>
fn take_stdin(&mut self) -> Option<ChildStdin<Self::Stdin>>
Takes the stdin handle.
Sourcefn take_stdout(&mut self) -> Option<ChildStdout<Self::Stdout>>
fn take_stdout(&mut self) -> Option<ChildStdout<Self::Stdout>>
Takes the stdout handle.
Sourcefn take_stderr(&mut self) -> Option<ChildStderr<Self::Stderr>>
fn take_stderr(&mut self) -> Option<ChildStderr<Self::Stderr>>
Takes the stderr handle.
Sourcefn id(&self) -> Option<u32>
fn id(&self) -> Option<u32>
Returns the OS-assigned process identifier associated with this child.
Sourcefn kill(&mut self) -> impl Future<Output = Result<()>> + Send
fn kill(&mut self) -> impl Future<Output = Result<()>> + Send
Forces the child process to exit.
If the child has already exited, an InvalidInput error is returned.
This is equivalent to sending a SIGKILL on Unix platforms.
Sourcefn try_wait(&mut self) -> Result<Option<ExitStatus>>
fn try_wait(&mut self) -> Result<Option<ExitStatus>>
Returns the exit status if the process has exited.
Unlike wait(), this method will not drop the stdin handle.
Sourcefn wait(&mut self) -> impl Future<Output = Result<ExitStatus>> + Send
fn wait(&mut self) -> impl Future<Output = Result<ExitStatus>> + Send
Drops the stdin handle and waits for the process to exit.
Closing the stdin of the process helps avoid deadlocks. It ensures that the process does not block waiting for input from the parent process while the parent waits for the child to exit.
Sourcefn wait_with_output(self) -> impl Future<Output = Result<Output>> + Send
fn wait_with_output(self) -> impl Future<Output = Result<Output>> + Send
Drops the stdin handle and collects the output of the process.
Closing the stdin of the process helps avoid deadlocks. It ensures that the process does not block waiting for input from the parent process while the parent waits for the child to exit.
In order to capture the output of the process, Command::stdout() and
Command::stderr() must be configured with Stdio::piped().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.