CheckedCommand

Struct CheckedCommand 

Source
pub struct CheckedCommand { /* private fields */ }
Expand description

A wrapper around std::process::Command which hides the original status/output methods and replaces them with the versions from checked_command::CommandExt

Implementations§

Source§

impl CheckedCommand

Source

pub fn as_std_command(&mut self) -> &mut Command

return a mutable reference to the wrapped std::process::Command this can be useful if the cammand has to be passed to a function or to access a extension trait for std::process::Command

Source

pub fn into_std_command(self) -> Command

converts this Command into a std::process::Command (basically unwrapping it).

Note that this function was intentionally provided instead of Into<Command> as the main reason for this wrapper is to prevent forgetting to check the exit status. As such it will forward all calls except spawn,status and output which normally tend to be the last function ever called on a command instances. Therefore converting a CheckedCommand to a Command is quite likely a bug. (Through there are some cases where it makes sense).

Source

pub fn new<S: AsRef<OsStr>>(program: S) -> CheckedCommand

creates a new CheckedCommand see std::process:Command::new for more details

Source

pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut CheckedCommand

calls std::process::Command::arg

Source

pub fn args<I, S>(&mut self, args: I) -> &mut CheckedCommand
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

calls std::process::Command::args

Source

pub fn env<K, V>(&mut self, key: K, val: V) -> &mut CheckedCommand
where K: AsRef<OsStr>, V: AsRef<OsStr>,

calls std::process::Command::env

Source

pub fn env_remove<K: AsRef<OsStr>>(&mut self, key: K) -> &mut CheckedCommand

calls std::process::Command::env_remove

Source

pub fn env_clear(&mut self) -> &mut CheckedCommand

calls std::process::Command::env_clear

Source

pub fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut CheckedCommand

calls std::process::Command::current_dir

Source

pub fn stdin(&mut self, cfg: Stdio) -> &mut CheckedCommand

calls std::process::Command::stdin

Source

pub fn stdout(&mut self, cfg: Stdio) -> &mut CheckedCommand

calls std::process::Command::stdout

Source

pub fn stderr(&mut self, cfg: Stdio) -> &mut CheckedCommand

calls std::process::Command::stderr

Source

pub fn spawn(&mut self) -> Result<CheckedChild, IoError>

calls std::process::Command::spawn and converts the Child into a CheckedChild

Source

pub fn output(&mut self) -> Result<Output, Error>

calls CommandExt::checked_output on the wrapped Command

Source

pub fn status(&mut self) -> Result<(), Error>

calls CommandExt::checked_status on the wrapped Command

Trait Implementations§

Source§

impl Debug for CheckedCommand

Source§

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

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

impl From<Command> for CheckedCommand

Source§

fn from(command: Command) -> CheckedCommand

Converts to this type from the input type.

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.