pub trait CommandRunner: Send + Sync {
// Required method
fn run(
&self,
executable: &str,
arguments: &[String],
) -> Result<CommandOutput>;
// Provided method
fn run_bytes(
&self,
executable: &str,
arguments: &[String],
) -> Result<CommandOutputBytes> { ... }
}Expand description
Abstraction over process execution.
FilesystemDataStore uses this to run commands in
run_and_record. Tests can provide a
mock that records calls without spawning processes.
Required Methods§
Provided Methods§
Sourcefn run_bytes(
&self,
executable: &str,
arguments: &[String],
) -> Result<CommandOutputBytes>
fn run_bytes( &self, executable: &str, arguments: &[String], ) -> Result<CommandOutputBytes>
Variant of Self::run that returns stdout as raw bytes.
Required for callers that decrypt binary payloads through a
subprocess (whole-file age / gpg preprocessors per
secrets.lex §4) — String::from_utf8_lossy on the
run path corrupts non-UTF-8 plaintext, so SSH binary
keys / X.509 DER certs / kubeconfig blobs would round-trip
to disk with replacement characters.
Stderr stays a String because diagnostic text is
human-readable in every shipped provider; if a future
caller emits non-UTF-8 stderr we’ll add a bytes variant
then.
Default impl converts a run() result by re-encoding the
String stdout as bytes — that’s safe (UTF-8 is a strict
subset of bytes) but does not recover bytes lost to
from_utf8_lossy upstream. Real impls (ShellCommandRunner)
must override and read stdout as raw bytes from the start.