pub mod fallback;
pub mod linux;
pub mod macos;
pub mod windows;
use anyhow::Result;
use std::path::Path;
use std::process::Output;
pub trait SandboxExecutor: Send + Sync {
fn name(&self) -> &'static str;
fn execute(
&self,
command: &str,
args: &[&str],
work_dir: &Path,
allow_network: bool,
) -> Result<Output>;
}
pub fn get_default_sandbox() -> Box<dyn SandboxExecutor> {
#[cfg(target_os = "linux")]
{
Box::new(linux::LinuxSandbox)
}
#[cfg(target_os = "macos")]
{
Box::new(macos::MacOsSandbox)
}
#[cfg(target_os = "windows")]
{
Box::new(windows::WindowsSandbox)
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
{
Box::new(fallback::FallbackSandbox)
}
}