Skip to main content

vx_shim/platform/
mod.rs

1//! Platform-specific execution implementations
2
3use anyhow::Result;
4use std::process::Command;
5
6use crate::config::ShimConfig;
7
8#[cfg(unix)]
9mod unix;
10#[cfg(windows)]
11mod windows;
12
13/// Platform-specific process executor
14pub struct PlatformExecutor {
15    #[cfg(windows)]
16    inner: windows::WindowsExecutor,
17    #[cfg(unix)]
18    inner: unix::UnixExecutor,
19}
20
21impl PlatformExecutor {
22    /// Create a new platform executor
23    pub fn new() -> Self {
24        Self {
25            #[cfg(windows)]
26            inner: windows::WindowsExecutor::new(),
27            #[cfg(unix)]
28            inner: unix::UnixExecutor::new(),
29        }
30    }
31
32    /// Execute a command with platform-specific behavior
33    pub fn execute(&self, command: Command, config: &ShimConfig) -> Result<i32> {
34        self.inner.execute(command, config)
35    }
36}
37
38impl Default for PlatformExecutor {
39    fn default() -> Self {
40        Self::new()
41    }
42}
43
44/// Trait for platform-specific execution
45trait PlatformExecutorTrait {
46    fn execute(&self, command: Command, config: &ShimConfig) -> Result<i32>;
47}