1use anyhow::Result;
4use std::process::Command;
5
6use crate::config::ShimConfig;
7
8#[cfg(unix)]
9mod unix;
10#[cfg(windows)]
11mod windows;
12
13pub struct PlatformExecutor {
15 #[cfg(windows)]
16 inner: windows::WindowsExecutor,
17 #[cfg(unix)]
18 inner: unix::UnixExecutor,
19}
20
21impl PlatformExecutor {
22 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 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
44trait PlatformExecutorTrait {
46 fn execute(&self, command: Command, config: &ShimConfig) -> Result<i32>;
47}