Trait cage::command_runner::Command [−][src]
pub trait Command { fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self; fn env<K, V>(&mut self, key: K, val: V) -> &mut Self
where
K: AsRef<OsStr>,
V: AsRef<OsStr>; fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self; fn status(&mut self) -> Result<ExitStatus>; fn command_failed_error(&self) -> ErrorKind; fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Self { ... } fn exec(&mut self) -> Result<()> { ... } }
A stripped down interface based on std::process::Command
. We use
this so we can mock out shell commands during tests.
Required methods
fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
[src]
Add an arugment to our command.
fn env<K, V>(&mut self, key: K, val: V) -> &mut Self where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
[src]
K: AsRef<OsStr>,
V: AsRef<OsStr>,
Set an environment variable for the process we’re about to run.
fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self
[src]
Set the current working directory for the child process we’ll create.
fn status(&mut self) -> Result<ExitStatus>
[src]
Run our command.
fn command_failed_error(&self) -> ErrorKind
[src]
Make an error representing a failure of this command.
Provided methods
fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Self
[src]
Add several arguments to our command.
fn exec(&mut self) -> Result<()>
[src]
Run our command as per status
, returning an error if the command
fails.
Implementors
impl Command for OsCommand
[src]
impl Command for OsCommand
[src]fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
[src]
fn args<S: AsRef<OsStr>>(&mut self, args: &[S]) -> &mut Self
[src]
fn env<K, V>(&mut self, key: K, val: V) -> &mut Self where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
[src]
K: AsRef<OsStr>,
V: AsRef<OsStr>,
fn current_dir<P: AsRef<Path>>(&mut self, dir: P) -> &mut Self
[src]
fn status(&mut self) -> Result<ExitStatus>
[src]
fn command_failed_error(&self) -> ErrorKind
[src]
impl Command for TestCommand
[src]
impl Command for TestCommand
[src]fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
[src]
fn env<K, V>(&mut self, _key: K, _val: V) -> &mut Self where
K: AsRef<OsStr>,
V: AsRef<OsStr>,
[src]
K: AsRef<OsStr>,
V: AsRef<OsStr>,