pub struct PipeCommand<const N: usize> {
pub commands: [Command; N],
}Expand description
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§
Source§impl<const N: usize> PipeCommand<N>
impl<const N: usize> PipeCommand<N>
Sourcepub fn new(commands: [Command; N]) -> Self
pub fn new(commands: [Command; N]) -> Self
Creates a new PipeCommand.
Sourcepub fn spawn(&mut self) -> Result<Child>
pub fn spawn(&mut self) -> Result<Child>
Sourcepub fn output(&mut self) -> Result<Output>
pub fn output(&mut self) -> Result<Output>
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.
Sourcepub fn status(&mut self) -> Result<ExitStatus>
pub fn status(&mut self) -> Result<ExitStatus>
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§
Auto Trait Implementations§
impl<const N: usize> Freeze for PipeCommand<N>
impl<const N: usize> !RefUnwindSafe for PipeCommand<N>
impl<const N: usize> Send for PipeCommand<N>
impl<const N: usize> Sync for PipeCommand<N>
impl<const N: usize> Unpin for PipeCommand<N>
impl<const N: usize> !UnwindSafe for PipeCommand<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more