Skip to main content

perl_subprocess_runtime/
lib.rs

1//! Subprocess execution abstraction for provider purity
2//!
3//! This crate provides a trait-based abstraction for subprocess execution,
4//! enabling testing with mock implementations and WASM compatibility.
5
6#![deny(unsafe_code)]
7#![cfg_attr(test, allow(clippy::panic, clippy::unwrap_used, clippy::expect_used))]
8#![warn(rust_2018_idioms)]
9#![warn(missing_docs)]
10
11mod error;
12#[cfg(not(target_arch = "wasm32"))]
13mod os_runtime;
14mod output;
15
16/// Mock subprocess runtime implementations for tests.
17pub mod mock;
18
19pub use error::SubprocessError;
20#[cfg(not(target_arch = "wasm32"))]
21pub use os_runtime::OsSubprocessRuntime;
22pub use output::SubprocessOutput;
23
24/// Abstraction trait for subprocess execution.
25pub trait SubprocessRuntime: Send + Sync {
26    /// Execute a command with the given arguments and optional stdin.
27    fn run_command(
28        &self,
29        program: &str,
30        args: &[&str],
31        stdin: Option<&[u8]>,
32    ) -> Result<SubprocessOutput, SubprocessError>;
33}
34
35#[cfg(test)]
36mod tests;