Trait CommandRunExt

Source
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§

Source

fn log_debug(&mut self) -> &mut Self

Log (at debug level) the full child commandline.

Source

fn run(&mut self) -> Result<()>

Execute the child process.

Source

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

Source

fn lifecycle_bind(&mut self) -> &mut Self

Ensure the child does not outlive the parent.

Source

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.

Source

fn run_get_string(&mut self) -> Result<String>

Execute the child process and capture its output as a string.

Source

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.

Source

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

Source§

fn run(&mut self) -> Result<()>

Synchronously execute the child, and return an error if the child exited unsuccessfully.

Source§

fn log_debug(&mut self) -> &mut Self

Output a debug-level log message with this command.

Source§

fn run_and_parse_json<T: DeserializeOwned>(&mut self) -> Result<T>

Synchronously execute the child, and parse its stdout as JSON.

Source§

fn lifecycle_bind(&mut self) -> &mut Self

Source§

fn run_get_output(&mut self) -> Result<Box<dyn BufRead>>

Source§

fn run_get_string(&mut self) -> Result<String>

Source§

fn run_with_cmd_context(&mut self) -> Result<()>

Source§

fn to_string_pretty(&self) -> String

Implementors§