Skip to main content

Redirection

Enum Redirection 

Source
pub enum Redirection {
    None,
    Pipe,
    Merge,
    File(File),
    Null,
}
Expand description

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

Redirection values are used for the stdin, stdout, and stderr parameters when configuring a subprocess via Exec or Pipeline.

Variants§

§

None

Do nothing with the stream.

The stream is typically inherited from the parent. The corresponding pipe field in Job 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.

§

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 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 stdout is equivalent to 1>&2 in the shell.

Specifying Redirection::Merge for stdin or specifying it for both stdout and stderr is invalid and will cause an error.

§

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.

§

Null

Redirect the stream to the null device (/dev/null on Unix, nul on Windows).

This is equivalent to Redirection::File with a null device file, but more convenient and portable.

Trait Implementations§

Source§

impl Debug for Redirection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromSink<File> for Redirection

Source§

fn from_sink(sink: File) -> Self

Create the output redirection from the given sink.
Source§

impl FromSink<Redirection> for Redirection

Source§

fn from_sink(sink: Redirection) -> Self

Create the output redirection from the given sink.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.