Expand description
The same API for programs without an async runtime.
Every call blocks until it is done. The calls run on a small runtime this module starts on first use and shares between threads. Calling them from inside an async runtime is refused (use the async API there).
Unlike the async crate::Sandbox, a blocking Sandbox deletes its sandbox when it is
dropped, like Python’s with Sandbox.create() as sbx:. Call Sandbox::detach to keep it.
use chainguard_sandbox::blocking::Sandbox;
use chainguard_sandbox::CreateOptions;
fn main() -> chainguard_sandbox::Result<()> {
let sbx = Sandbox::create(CreateOptions::default())?; // deleted when sbx is dropped
println!("{}", sbx.commands.run("echo hello")?.stdout);
Ok(())
}Structs§
- Command
Handle - Blocking
crate::CommandHandle. - Commands
- Blocking
crate::Commands. - Files
- Blocking
crate::Files. - Sandbox
- A handle to one sandbox, deleted when dropped (see
Sandbox::detach).