pub trait SandboxBackend: Send + Sync {
Show 13 methods
// Required methods
fn backend_type(&self) -> &'static str;
fn is_available(&self) -> bool;
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 PoolConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn start<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
config: &'life2 PodSandboxConfig,
pool_config: &'life3 PoolConfig,
annotations: &'life4 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SandboxHandle>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_pids<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Vec<u32>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn supports_exec(&self) -> bool;
fn exec_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
command: &'life2 [String],
timeout_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(i32, Vec<u8>, Vec<u8>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn deliver_namespace<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_namespace: Namespace,
_subject: Subject,
_transport: NamespaceTransport,
) -> Pin<Box<dyn Future<Output = Result<NamespaceDelivery>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn update_resources<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_resources: &'life2 LinuxContainerResources,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn container_stats<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Option<(CpuUsage, MemoryUsage)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Pluggable sandbox runtime backend.
Implementors manage the full sandbox lifecycle: create → start → stop →
destroy. The pool calls these methods and stores the returned
SandboxHandle on the PodSandbox.
Required Methods§
Sourcefn backend_type(&self) -> &'static str
fn backend_type(&self) -> &'static str
Human-readable backend name (e.g. "kata", "nspawn").
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Check whether the backend’s runtime dependencies are available.
Sourcefn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 PoolConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 PoolConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
One-time initialisation (verify paths, enable rootless mode, …).
Sourcefn start<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
config: &'life2 PodSandboxConfig,
pool_config: &'life3 PoolConfig,
annotations: &'life4 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SandboxHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn start<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
config: &'life2 PodSandboxConfig,
pool_config: &'life3 PoolConfig,
annotations: &'life4 HashMap<String, String>,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SandboxHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Start a sandbox and return the backend-specific handle.
Sourcefn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gracefully stop a running sandbox.
Sourcefn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn destroy<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Destroy a sandbox and clean up all resources.
Sourcefn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reset<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 mut PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reset a sandbox for warm-pool reuse.
Returns true if the sandbox can be reused in-place (e.g. Kata keeps
the VM running). Returns false if the sandbox is ephemeral and must
be recreated (e.g. nspawn).
Sourcefn get_pids<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Vec<u32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_pids<'life0, 'life1, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Vec<u32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get PIDs belonging to this sandbox (for monitoring / cgroup ops).
Sourcefn supports_exec(&self) -> bool
fn supports_exec(&self) -> bool
Whether exec_sync is supported.
Sourcefn exec_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
command: &'life2 [String],
timeout_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(i32, Vec<u8>, Vec<u8>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exec_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sandbox: &'life1 PodSandbox,
command: &'life2 [String],
timeout_secs: u64,
) -> Pin<Box<dyn Future<Output = Result<(i32, Vec<u8>, Vec<u8>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run a command synchronously inside the sandbox.
Provided Methods§
Sourcefn deliver_namespace<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_namespace: Namespace,
_subject: Subject,
_transport: NamespaceTransport,
) -> Pin<Box<dyn Future<Output = Result<NamespaceDelivery>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn deliver_namespace<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_namespace: Namespace,
_subject: Subject,
_transport: NamespaceTransport,
) -> Pin<Box<dyn Future<Output = Result<NamespaceDelivery>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deliver a composed Namespace to this sandbox’s guest via
transport (#635 — the narrowed SandboxBackend surface epic #508 is
converging on).
A backend’s job here is exactly: attach namespace (already fully
composed — rootfs + injected mounts — by the caller; composition
itself is NOT this method’s job) to the running/starting guest, using
whichever transport variant it supports. subject is the policy/
audit principal the namespace is served under (threaded into every VFS
op at the Mount boundary).
Default: unsupported. Not every backend has been re-grounded onto this method yet (see #617/#619/nspawn re-grounding, blocked on this issue); backends that haven’t should fail closed rather than silently no-op.
Sourcefn update_resources<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_resources: &'life2 LinuxContainerResources,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update_resources<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
_resources: &'life2 LinuxContainerResources,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Apply resource limits to a running sandbox (optional).
Sourcefn container_stats<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Option<(CpuUsage, MemoryUsage)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn container_stats<'life0, 'life1, 'async_trait>(
&'life0 self,
_sandbox: &'life1 PodSandbox,
) -> Pin<Box<dyn Future<Output = Result<Option<(CpuUsage, MemoryUsage)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch live per-container resource usage from the sandbox’s guest.
Returns Some((cpu, memory)) sourced from inside the sandbox (e.g.
the kata-agent stats RPC / guest cgroups), or None when the backend
cannot observe the guest (default). Callers fall back to
placeholder/zeroed usage when this is None, so a backend that has no
in-guest visibility does not have to synthesise fake numbers.