MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / from_str

Method from_str

crates/openshell-sandbox/src/main.rs:52–72  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected