CommandRunExt

Trait CommandRunExt 

Source
pub trait CommandRunExt {
    // Required methods
    fn log_debug(&mut self) -> &mut Self;
    fn run_inherited(&mut self) -> Result<()>;
    fn run_capture_stderr(&mut self) -> Result<()>;
    fn run_inherited_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_inherited(&mut self) -> Result<()>

Execute the child process and wait for it to exit.

§Streams
  • stdin, stdout, stderr: All inherited
§Errors

An non-successful exit status will result in an error.

Source

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

Execute the child process and wait for it to exit.

§Streams
  • stdin, stdout: Inherited
  • stderr: captured and included in error
§Errors

An non-successful exit status will result in an error.

Source

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

Execute the child process and wait for it to exit; the complete argument list will be included in the error.

§Streams
  • stdin, stdout, stderr: All nherited
§Errors

An non-successful exit status will result in an error.

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_capture_stderr 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. This uses run_capture_stderr internally.

Source

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

Execute the child process, parsing its stdout as JSON. This uses run_capture_stderr 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_capture_stderr(&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 run_inherited(&mut self) -> Result<()>

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_inherited_with_cmd_context(&mut self) -> Result<()>

Source§

fn to_string_pretty(&self) -> String

Implementors§