Enum subprocess::Redirection [] [src]

pub enum Redirection {
    None,
    File(File),
    Pipe,
    Merge,
}

Instruction what to do with a stream in the child process.

Redirection values are used for the stdin, stdout, and stderr field of the PopenConfig struct. They tell Popen::create how to set up the standard streams in the child process and the corresponding fields of the Popen struct in the parent.

Variants

Do nothing with the stream.

The stream is typically inherited from the parent. The field in Popen corresponding to the stream will be None.

Redirect the stream to the specified open File.

This does not create a pipe, it simply spawns the child so that the specified stream sees that file. The child can read from or write to the provided file on its own, without any intervention by the parent.

The field in Popen corresponding to the stream will be None.

Redirect the stream to a pipe.

This variant requests that a stream be redirected to a unidirectional pipe. One end of the pipe is passed to the child process and configured as one of its standard streams, and the other end is available to the parent for communicating with the child.

The field with Popen corresponding to the stream will be Some(file), File being the parent's end of the pipe.

Merge the stream to the other output stream.

This variant is only valid when configuring redirection of standard output and standard error. Using Redirection::Merge for PopenConfig::stderr requests the child's stderr to refer to the same underlying file as the child's stdout (which may or may not itself be redirected), equivalent to the 2>&1 operator of the Bourne shell. Analogously, using Redirection::Merge for PopenConfig::stdout is equivalent to 1>&2 in the shell.

Specifying Redirection::Merge for PopenConfig::stdin or specifying it for both stdout and stderr is invalid and will cause Popen::create to return Err(PopenError::LogicError).

The field in Popen corresponding to the stream will be None.

Methods

impl Redirection
[src]

[src]

Clone the underlying Redirection, or return an error.

Can fail in File variant.

Trait Implementations

impl Debug for Redirection
[src]

[src]

Formats the value using the given formatter.