pub struct RustSandboxExecutor { /* private fields */ }Expand description
The flagship Rust-authored code execution backend.
Compiles and executes authored Rust using a host-local process approach. Phase 1 is honest about isolation: it can enforce timeouts and output truncation, but cannot enforce network or filesystem restrictions.
§Backend Capability Reporting
RustSandboxExecutor reports its capabilities truthfully through
BackendCapabilities. The phase 1 implementation uses host-local
process execution (rustc + spawned binary), so:
| Capability | Enforced | Reason |
|---|---|---|
| Isolation class | HostLocal | Runs as a local process, not in a container |
| Network policy | No | Host-local processes inherit host network access |
| Filesystem policy | No | Host-local processes inherit host filesystem access |
| Environment policy | No | Host-local processes inherit host environment |
| Timeout | Yes | Enforced via tokio::time::timeout |
| Structured output | Yes | Harness extracts JSON from last stdout line |
| Process execution | No | User code cannot spawn child processes through the harness |
| Persistent workspace | No | Each execution uses a fresh temp directory |
| Interactive sessions | No | Single-shot execution only |
Callers should use [validate_policy] to check whether a requested
[SandboxPolicy] is compatible with these capabilities before execution.
If a policy requests a control the backend cannot enforce (e.g., disabled
network), validation fails with ExecutionError::UnsupportedPolicy.
§Example
use adk_code::{CodeExecutor, RustSandboxExecutor, ExecutionIsolation};
let executor = RustSandboxExecutor::default();
assert_eq!(executor.name(), "rust-sandbox");
assert_eq!(executor.capabilities().isolation, ExecutionIsolation::HostLocal);
assert!(executor.capabilities().enforce_timeout);
assert!(!executor.capabilities().enforce_network_policy);Implementations§
Source§impl RustSandboxExecutor
impl RustSandboxExecutor
Sourcepub fn new(config: RustSandboxConfig) -> Self
pub fn new(config: RustSandboxConfig) -> Self
Create a new executor with the given configuration.
Trait Implementations§
Source§impl Clone for RustSandboxExecutor
impl Clone for RustSandboxExecutor
Source§fn clone(&self) -> RustSandboxExecutor
fn clone(&self) -> RustSandboxExecutor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more