[][src]Struct procmd::PipeCommand

pub struct PipeCommand<const N: usize> {
    pub commands: [Command; N],
}

Multiple commands that will be piped.

A PipeCommand can be created by either using the new method or by using the cmd! macro.

Examples

Using the new method combined with Command::new and a simple use of the cmd! macro:

use procmd::{cmd, PipeCommand};
use std::process::Command;

let mut pipe_cmd = PipeCommand::new([Command::new("ls"), cmd!("grep", "example")]);
let child = pipe_cmd.spawn()?;

Using the cmd! macro with the => token to generate a PipeCommand and calling the status method to get the exit status:

use procmd::cmd;

let mut pipe_cmd = cmd!("ls" => "grep", "example");
let exit_status = pipe_cmd.status()?;

Fields

commands: [Command; N]

The commands.

Implementations

impl<const N: usize> PipeCommand<N>[src]

pub fn new(commands: [Command; N]) -> Self[src]

Creates a new PipeCommand.

pub fn spawn(&mut self) -> Result<Child>[src]

Spawns all commands and returns the Child of the last command.

Panics

This method panics if commands is empty.

pub fn output(&mut self) -> Result<Output>[src]

Returns the Output of the last command.

Note that this method still calls Command::spawn on all commands except the last one.

Panics

This method panics if commands is empty.

pub fn status(&mut self) -> Result<ExitStatus>[src]

Returns the ExitStatus of the last command.

Note that this method still calls Command::spawn on all commands except the last one.

Panics

This method panics if commands is empty.

Trait Implementations

impl<const N: usize> Debug for PipeCommand<N>[src]

Auto Trait Implementations

impl<const N: usize> RefUnwindSafe for PipeCommand<N>[src]

impl<const N: usize> Send for PipeCommand<N>[src]

impl<const N: usize> Sync for PipeCommand<N>[src]

impl<const N: usize> Unpin for PipeCommand<N>[src]

impl<const N: usize> UnwindSafe for PipeCommand<N>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.