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 creates a unidirectional pipe for the standard stream. One end is passed to the child process and configured as one of its standard streams, and the other end is available to the parent as a File in the corresponding field of the Popen struct.

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

Merge the stream to the other output stream.

This is only valid for output streams. Using Redirection::Merge for PopenConfig::stderr requests the child's stderr to be the same underlying file as the child's output stream (whatever that is), 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).

Methods

impl Redirection
[src]

Clone the underlying Redirection, or return an error.

Can fail in File variant.

Trait Implementations

impl Debug for Redirection
[src]

Formats the value using the given formatter.