pub trait ChildExt: Sized {
    type Error: From<Error>;

    // Required methods
    fn output_checked_as<O, R, E>(
        self,
        succeeded: impl Fn(OutputContext<O>) -> Result<R, E>
    ) -> Result<R, E>
       where O: Debug + OutputLike + 'static + TryFrom<Output>,
             <O as TryFrom<Output>>::Error: Display + Send + Sync,
             E: From<Self::Error>;
    fn try_wait_checked_as<R, E>(
        &mut self,
        succeeded: impl Fn(TryWaitContext) -> Result<R, E>
    ) -> Result<R, E>
       where E: From<Self::Error>;
    fn wait_checked_as<R, E>(
        &mut self,
        succeeded: impl Fn(OutputContext<ExitStatus>) -> Result<R, E>
    ) -> Result<R, E>
       where E: From<Self::Error>;
    fn log(&self) -> Result<(), Self::Error>;

    // Provided methods
    fn output_checked_with<O, E>(
        self,
        succeeded: impl Fn(&O) -> Result<(), Option<E>>
    ) -> Result<O, Self::Error>
       where O: Debug + OutputLike + TryFrom<Output> + Send + Sync + 'static,
             <O as TryFrom<Output>>::Error: Display + Send + Sync,
             E: Debug + Display + Send + Sync + 'static { ... }
    fn output_checked(self) -> Result<Output, Self::Error> { ... }
    fn output_checked_utf8(self) -> Result<Utf8Output, Self::Error> { ... }
    fn output_checked_with_utf8<E>(
        self,
        succeeded: impl Fn(&Utf8Output) -> Result<(), Option<E>>
    ) -> Result<Utf8Output, Self::Error>
       where E: Display + Debug + Send + Sync + 'static { ... }
    fn try_wait_checked(&mut self) -> Result<Option<ExitStatus>, Self::Error> { ... }
    fn wait_checked_with<E>(
        &mut self,
        succeeded: impl Fn(ExitStatus) -> Result<(), Option<E>>
    ) -> Result<ExitStatus, Self::Error>
       where E: Debug + Display + Send + Sync + 'static { ... }
    fn wait_checked(&mut self) -> Result<ExitStatus, Self::Error> { ... }
}
Expand description

Checked methods for Child processes.

This trait is largely the same as CommandExt, with the difference that the ChildExt::output_checked methods take self as an owned parameter and the CommandExt::output_checked methods take self as a mutable reference.

Additionally, methods that return an ExitStatus are named wait_checked instead of status_checked, to match the method names on Child.

Required Associated Types§

source

type Error: From<Error>

The error type returned from methods on this trait.

Required Methods§

source

fn output_checked_as<O, R, E>( self, succeeded: impl Fn(OutputContext<O>) -> Result<R, E> ) -> Result<R, E>
where O: Debug + OutputLike + 'static + TryFrom<Output>, <O as TryFrom<Output>>::Error: Display + Send + Sync, E: From<Self::Error>,

Wait for the process to complete, capturing its output. succeeded is called and returned to determine if the command succeeded.

See CommandExt::output_checked_as for more information.

source

fn try_wait_checked_as<R, E>( &mut self, succeeded: impl Fn(TryWaitContext) -> Result<R, E> ) -> Result<R, E>
where E: From<Self::Error>,

Check if the process has exited.

The succeeded closure is called and returned to determine the result.

Errors while attempting to retrieve the process’s exit status are returned as WaitErrors.

See Child::try_wait for more information.

source

fn wait_checked_as<R, E>( &mut self, succeeded: impl Fn(OutputContext<ExitStatus>) -> Result<R, E> ) -> Result<R, E>
where E: From<Self::Error>,

Wait for the process to exit. succeeded is called and returned to determine if the command succeeded.

See CommandExt::status_checked_as and Child::wait for more information.

source

fn log(&self) -> Result<(), Self::Error>

Log the command that will be run.

With the tracing feature enabled, this will emit a debug-level log with message Executing command and a command field containing the displayed command (by default, shell-quoted).

Provided Methods§

source

fn output_checked_with<O, E>( self, succeeded: impl Fn(&O) -> Result<(), Option<E>> ) -> Result<O, Self::Error>
where O: Debug + OutputLike + TryFrom<Output> + Send + Sync + 'static, <O as TryFrom<Output>>::Error: Display + Send + Sync, E: Debug + Display + Send + Sync + 'static,

Wait for the process to complete, capturing its output. succeeded is called and used to determine if the command succeeded and (optionally) to add an additional message to the error returned.

See CommandExt::output_checked_with and Child::wait_with_output for more information.

source

fn output_checked(self) -> Result<Output, Self::Error>

Wait for the process to complete, capturing its output. If the command exits with a non-zero exit code, an error is raised.

See CommandExt::output_checked and Child::wait_with_output for more information.

source

fn output_checked_utf8(self) -> Result<Utf8Output, Self::Error>

Wait for the process to exit, capturing its output and decoding it as UTF-8. If the command exits with a non-zero exit code, an error is raised.

See CommandExt::output_checked_utf8 and Child::wait_with_output for more information.

source

fn output_checked_with_utf8<E>( self, succeeded: impl Fn(&Utf8Output) -> Result<(), Option<E>> ) -> Result<Utf8Output, Self::Error>
where E: Display + Debug + Send + Sync + 'static,

Wait for the process to exit, capturing its output and decoding it as UTF-8. succeeded is called and used to determine if the command succeeded and (optionally) to add an additional message to the error returned.

See CommandExt::output_checked_with_utf8 and Child::wait_with_output for more information.

source

fn try_wait_checked(&mut self) -> Result<Option<ExitStatus>, Self::Error>

Check if the process has exited and, if it failed, return an error.

Errors while attempting to retrieve the process’s exit status are transformed into WaitErrors.

See Child::try_wait for more information.

source

fn wait_checked_with<E>( &mut self, succeeded: impl Fn(ExitStatus) -> Result<(), Option<E>> ) -> Result<ExitStatus, Self::Error>
where E: Debug + Display + Send + Sync + 'static,

Wait for the process to exit. succeeded is called and used to determine if the command succeeded and (optionally) to add an additional message to the error returned.

See CommandExt::status_checked_with and Child::wait for more information.

source

fn wait_checked(&mut self) -> Result<ExitStatus, Self::Error>

Wait for the process to exit. If the command exits with a non-zero status code, an error is raised containing information about the command that was run.

See CommandExt::status_checked and Child::wait for more information.

Object Safety§

This trait is not object safe.

Implementors§