CommandExt

Trait CommandExt 

pub trait CommandExt {
    type Child: ChildExt;

    // Required methods
    fn spawn_with_logging(
        &mut self,
        target: Cow<'static, str>,
        stdout_level: Option<Level>,
        stderr_level: Option<Level>,
    ) -> Result<Self::Child>;
    fn status_with_logging(
        &mut self,
        target: &str,
        stdout_level: Option<Level>,
        stderr_level: Option<Level>,
    ) -> impl Future<Output = Result<ExitStatus>>;
    fn output_with_logging(
        &mut self,
        target: &str,
        stdout_level: Option<Level>,
        stderr_level: Option<Level>,
    ) -> impl Future<Output = Result<Output>>;
}
Expand description

Extensions for tokio::process::Command.

Required Associated Types§

Required Methods§

fn spawn_with_logging( &mut self, target: Cow<'static, str>, stdout_level: Option<Level>, stderr_level: Option<Level>, ) -> Result<Self::Child>

Spawns a new process while redirecting its output to log.

stdout_level and stderr_level specify the log level to use for the respective streams. If None, the stream will not be redirected.

The redirection is done in a background task which will stop when the child process exits.

fn status_with_logging( &mut self, target: &str, stdout_level: Option<Level>, stderr_level: Option<Level>, ) -> impl Future<Output = Result<ExitStatus>>

Spawns a new process while redirecting its output to log and waits for it to exit.

See CommandExt::spawn_with_logging for more information.

fn output_with_logging( &mut self, target: &str, stdout_level: Option<Level>, stderr_level: Option<Level>, ) -> impl Future<Output = Result<Output>>

Spawns a new process and collects its output or redirects it to log.

If stdout_level or stderr_level is Some(_), the respective stream will be sent to log, otherwise it will be collected to the returned Output.

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.

Implementors§