pub trait ScriptIo: Send + Sync {
// Required methods
fn http_get(
&self,
url: &str,
headers: BTreeMap<String, String>,
) -> Result<String, String>;
fn http_post(
&self,
url: &str,
body: &str,
headers: BTreeMap<String, String>,
) -> Result<String, String>;
fn run_shell(
&self,
cmd: TokioCommand,
timeout: Duration,
) -> Result<String, String>;
fn read_file(&self, path: &Path) -> Result<String, String>;
fn write_file(&self, path: &Path, content: &str) -> Result<String, String>;
fn env_var(&self, name: &str) -> Result<String, String>;
}Expand description
The raw I/O a DaemonScriptHost performs, behind a seam so the host’s
permission/confinement logic is testable without real side effects.
Required Methods§
Sourcefn http_get(
&self,
url: &str,
headers: BTreeMap<String, String>,
) -> Result<String, String>
fn http_get( &self, url: &str, headers: BTreeMap<String, String>, ) -> Result<String, String>
Perform an HTTP GET, returning the response body (or an error message).
Sourcefn http_post(
&self,
url: &str,
body: &str,
headers: BTreeMap<String, String>,
) -> Result<String, String>
fn http_post( &self, url: &str, body: &str, headers: BTreeMap<String, String>, ) -> Result<String, String>
Perform an HTTP POST, returning the response body (or an error message).
Sourcefn run_shell(
&self,
cmd: TokioCommand,
timeout: Duration,
) -> Result<String, String>
fn run_shell( &self, cmd: TokioCommand, timeout: Duration, ) -> Result<String, String>
Run a prepared shell command (already sandbox-wrapped and pointed at the
workdir by the host), enforcing timeout, and return its combined output.
Sourcefn read_file(&self, path: &Path) -> Result<String, String>
fn read_file(&self, path: &Path) -> Result<String, String>
Read the file at an already-confined absolute path.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".