pub enum Redirection {
None,
Pipe,
Merge,
File(File),
RcFile(Rc<File>),
}Expand description
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§
None
Do nothing with the stream.
The stream is typically inherited from the parent. The field in Popen corresponding
to the stream will be None.
Pipe
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
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.
File(File)
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.
RcFile(Rc<File>)
Like File, but the file is specified as Rc.
This allows the same file to be used in multiple redirections.
Implementations§
Source§impl Redirection
impl Redirection
Sourcepub fn try_clone(&self) -> Result<Redirection>
pub fn try_clone(&self) -> Result<Redirection>
Clone the underlying Redirection, or return an error.
Can fail in File variant.