1use std::collections::HashMap;
2use std::path::PathBuf;
3use std::time::Duration;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct SandboxConfig {
10 pub work_dir: PathBuf,
12
13 #[serde(default)]
15 pub mounts: Vec<MountPoint>,
16
17 #[serde(default)]
19 pub env_vars: HashMap<String, String>,
20
21 #[serde(default = "default_timeout")]
23 pub timeout: Duration,
24
25 #[serde(default = "default_memory_limit")]
27 pub memory_limit_bytes: u64,
28
29 #[serde(default = "default_fuel_limit")]
31 pub fuel_limit: u64,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct MountPoint {
37 pub host_path: PathBuf,
39
40 pub guest_path: String,
42
43 #[serde(default)]
45 pub writable: bool,
46}
47
48fn default_timeout() -> Duration {
49 Duration::from_secs(30)
50}
51
52fn default_memory_limit() -> u64 {
53 512 * 1024 * 1024 }
55
56fn default_fuel_limit() -> u64 {
57 1_000_000_000 }
59
60impl Default for SandboxConfig {
61 fn default() -> Self {
62 Self {
63 work_dir: PathBuf::from("."),
64 mounts: Vec::new(),
65 env_vars: HashMap::new(),
66 timeout: default_timeout(),
67 memory_limit_bytes: default_memory_limit(),
68 fuel_limit: default_fuel_limit(),
69 }
70 }
71}