pub struct Sandbox { /* private fields */ }Expand description
A configured sandbox, ready to run a command.
Implementations§
Source§impl Sandbox
impl Sandbox
pub fn builder() -> SandboxBuilder
pub fn config(&self) -> &Config
Sourcepub fn run(&self) -> Result<i32, Error>
pub fn run(&self) -> Result<i32, Error>
Boot the container and run PID 1, returning its exit code.
Assembles the root (overlay of the read-only image over a writable
tmpfs), preconfigures /etc + the environment host-side, then loads and
runs PID 1 — the shell in RunMode::Nude, or init in
RunMode::Booted (falling back to the shell if no init is present).
The PID-1 binary is read out of the assembled guest root, so this needs a
root that actually contains it (see SandboxBuilder::root_dir /
root_squashfs). The binary must be a static ELF today — dynamic linking
is not yet wired.
Sourcepub fn exec_elf(&self, elf: &[u8]) -> Result<i32, Error>
pub fn exec_elf(&self, elf: &[u8]) -> Result<i32, Error>
Load and run a statically-linked ELF64 image, returning its exit code.
This is the full pipeline — loader → backend → kernel run/serve loop —
that Sandbox::run will call once image/filesystem resolution reads
the target binary out of the guest root. Exposed now so it’s testable
and embeddable ahead of that.