Skip to main content

CommandRunner

Trait CommandRunner 

Source
pub trait CommandRunner:
    Debug
    + Send
    + Sync {
    // Required methods
    fn run<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        program: &'life1 str,
        args: &'life2 [&'life3 str],
    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn run_with_stdin<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        program: &'life1 str,
        args: &'life2 [&'life3 str],
        stdin_data: &'life4 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
}
Expand description

Trait for executing CLI commands. Abstracts process spawning for testability.

Required Methods§

Source

fn run<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, program: &'life1 str, args: &'life2 [&'life3 str], ) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Execute a command with the given program and arguments.

§Errors

Returns std::io::Error if the command cannot be spawned.

Source

fn run_with_stdin<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, program: &'life1 str, args: &'life2 [&'life3 str], stdin_data: &'life4 [u8], ) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Execute a command with the given program and arguments, writing stdin_data to the child process’s standard input.

This avoids exposing sensitive values (such as tokens) in process arguments, where they would be visible to other users via ps.

§Errors

Returns std::io::Error if the command cannot be spawned or if writing to its standard input fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§