pub trait CommandRunExt {
// Required methods
fn log_debug(&mut self) -> &mut Self;
fn run(&mut self) -> Result<()>;
fn run_with_cmd_context(&mut self) -> Result<()>;
fn lifecycle_bind(&mut self) -> &mut Self;
fn run_get_output(&mut self) -> Result<Box<dyn BufRead>>;
fn run_get_string(&mut self) -> Result<String>;
fn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>;
fn to_string_pretty(&self) -> String;
}
Expand description
Helpers intended for std::process::Command
.
Required Methods§
Sourcefn run_with_cmd_context(&mut self) -> Result<()>
fn run_with_cmd_context(&mut self) -> Result<()>
Execute the child process. In case of failure, include the command and its arguments in the error context
Sourcefn lifecycle_bind(&mut self) -> &mut Self
fn lifecycle_bind(&mut self) -> &mut Self
Ensure the child does not outlive the parent.
Sourcefn run_get_output(&mut self) -> Result<Box<dyn BufRead>>
fn run_get_output(&mut self) -> Result<Box<dyn BufRead>>
Execute the child process and capture its output. This uses run
internally
and will return an error if the child process exits abnormally.
Sourcefn run_get_string(&mut self) -> Result<String>
fn run_get_string(&mut self) -> Result<String>
Execute the child process and capture its output as a string.
Sourcefn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>
fn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>
Execute the child process, parsing its stdout as JSON. This uses run
internally
and will return an error if the child process exits abnormally.
Sourcefn to_string_pretty(&self) -> String
fn to_string_pretty(&self) -> String
Print the command as it would be typed into a terminal
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl CommandRunExt for Command
impl CommandRunExt for Command
Source§fn run(&mut self) -> Result<()>
fn run(&mut self) -> Result<()>
Synchronously execute the child, and return an error if the child exited unsuccessfully.
Source§fn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>
fn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>
Synchronously execute the child, and parse its stdout as JSON.