Trait Child

Source
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§

Source

type Stdin: Stdin + IntoStdio

The standard input (stdin) handle type.

Source

type Stdout: Stdout + IntoStdio

The standard output (stdout) handle type.

Source

type Stderr: Stderr + IntoStdio

The standard error (stderr) handle type.

Required Methods§

Source

fn stdin(&self) -> Option<ChildStdin<&Self::Stdin>>

Returns the stdin handle if it was configured.

Source

fn stdout(&self) -> Option<ChildStdout<&Self::Stdout>>

Returns the stdout handle if it was configured.

Source

fn stderr(&self) -> Option<ChildStderr<&Self::Stderr>>

Returns the stderr handle if it was configured.

Source

fn stdin_mut(&mut self) -> Option<ChildStdin<&mut Self::Stdin>>

Returns a mutable reference to the stdin handle if it was configured.

Source

fn stdout_mut(&mut self) -> Option<ChildStdout<&mut Self::Stdout>>

Returns a mutable reference to the stdout handle if it was configured.

Source

fn stderr_mut(&mut self) -> Option<ChildStderr<&mut Self::Stderr>>

Returns a mutable reference to the stderr handle if it was configured.

Source

fn set_stdin(&mut self, stdin: Option<Self::Stdin>)

Sets the stdin handle.

Source

fn set_stdout(&mut self, stdout: Option<Self::Stdout>)

Sets the stdout handle.

Source

fn set_stderr(&mut self, stderr: Option<Self::Stderr>)

Sets the stderr handle.

Source

fn take_stdin(&mut self) -> Option<ChildStdin<Self::Stdin>>

Takes the stdin handle.

Source

fn take_stdout(&mut self) -> Option<ChildStdout<Self::Stdout>>

Takes the stdout handle.

Source

fn take_stderr(&mut self) -> Option<ChildStderr<Self::Stderr>>

Takes the stderr handle.

Source

fn id(&self) -> Option<u32>

Returns the OS-assigned process identifier associated with this child.

Source

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.

Source

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.

Source

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.

Source

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.

Implementors§