CommandRunner

Trait CommandRunner 

Source
pub trait CommandRunner {
    // Required method
    fn run(&self, program: &str, args: &[&str]) -> Result<String, CommandError>;
}
Expand description

What: Abstract command execution interface used for spawning helper binaries such as pacman.

Inputs:

  • program: Executable name to run (for example, "pacman").
  • args: Slice of positional arguments passed to the executable.

Output:

  • Ok(String) containing UTF-8 stdout on success.
  • Err(CommandError) when the invocation fails or stdout is not valid UTF-8.

§Errors

  • Returns Err(CommandError::Io) when command spawning or execution fails
  • Returns Err(CommandError::Utf8) when stdout cannot be decoded as UTF-8
  • Returns Err(CommandError::Failed) when the command exits with a non-zero status

Details:

  • Implementations may stub command results to enable deterministic unit testing.
  • Production code relies on SystemCommandRunner.

Required Methods§

Source

fn run(&self, program: &str, args: &[&str]) -> Result<String, CommandError>

§Errors
  • Returns Err(CommandError::Io) when command spawning or execution fails
  • Returns Err(CommandError::Utf8) when stdout cannot be decoded as UTF-8
  • Returns Err(CommandError::Failed) when the command exits with a non-zero status

Implementors§