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#![warn(clippy::all)]
11
12mod error;
13#[cfg(not(target_arch = "wasm32"))]
14mod os_runtime;
15mod output;
16
17/// Mock subprocess runtime implementations for tests.
18pub mod mock;
19
20pub use error::SubprocessError;
21#[cfg(not(target_arch = "wasm32"))]
22pub use os_runtime::OsSubprocessRuntime;
23pub use output::SubprocessOutput;
24
25/// Abstraction trait for subprocess execution.
26pub trait SubprocessRuntime: Send + Sync {
27    /// Execute a command with the given arguments and optional stdin.
28    fn run_command(
29        &self,
30        program: &str,
31        args: &[&str],
32        stdin: Option<&[u8]>,
33    ) -> Result<SubprocessOutput, SubprocessError>;
34}
35
36#[cfg(test)]
37mod tests;