| 50 | type Err = String; |
| 51 | |
| 52 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 53 | let mut mode = Self { |
| 54 | network: false, |
| 55 | process: false, |
| 56 | }; |
| 57 | for part in s.split(',').map(str::trim).filter(|p| !p.is_empty()) { |
| 58 | match part { |
| 59 | "network" => mode.network = true, |
| 60 | "process" => mode.process = true, |
| 61 | other => { |
| 62 | return Err(format!( |
| 63 | "unknown mode component '{other}' (expected 'network' and/or 'process')" |
| 64 | )); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | if !mode.network && !mode.process { |
| 69 | return Err("--mode must enable at least one of: network, process".into()); |
| 70 | } |
| 71 | Ok(mode) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /// `OpenShell` Sandbox - process isolation and monitoring. |