pub trait SandboxBackend: Send + Sync {
// Required methods
fn read<'a>(&'a self, path: &'a str) -> BoxFuture<'a, Result<String>>;
fn read_bytes<'a>(
&'a self,
path: &'a str,
max_bytes: usize,
) -> BoxFuture<'a, Result<Vec<u8>>>;
fn write<'a>(
&'a self,
path: &'a str,
content: &'a str,
) -> BoxFuture<'a, Result<()>>;
fn execute<'a>(
&'a self,
command: &'a str,
sandbox_mode: SandboxMode,
network_access: NetworkAccess,
mode: CommandMode,
output: CommandOutputSink,
) -> BoxFuture<'a, Result<CommandOutput>>;
// Provided methods
fn isolated_execution(&self) -> Result<Arc<dyn SandboxBackend>> { ... }
fn temporary_directory(&self) -> Option<PathBuf> { ... }
fn start_worker(
&self,
_command: &WorkerCommand,
_sandbox_mode: SandboxMode,
_network_access: NetworkAccess,
) -> Result<WorkerProcess> { ... }
fn worker_connection<'a>(
&'a self,
_session_id: &'a str,
_sandbox_mode: SandboxMode,
) -> BoxFuture<'a, Result<DuplexStream>> { ... }
fn execute_authorized<'a>(
&'a self,
_command: &'a str,
_sandbox_mode: SandboxMode,
_network_access: NetworkAccess,
_mode: CommandMode,
_output: CommandOutputSink,
_authorization: &'a CommandAuthorization,
) -> BoxFuture<'a, Result<Option<CommandOutput>>> { ... }
}Expand description
Implements one sandbox execution environment.
Returned futures are Send and may be dropped during execution. Backends
own cancellation cleanup for the processes and resources they launch;
dropping a future must not leave unmanaged commands running. Sandbox
owns approval and background-command tracking, not arbitrary backend cleanup.
Required Methods§
Sourcefn read_bytes<'a>(
&'a self,
path: &'a str,
max_bytes: usize,
) -> BoxFuture<'a, Result<Vec<u8>>>
fn read_bytes<'a>( &'a self, path: &'a str, max_bytes: usize, ) -> BoxFuture<'a, Result<Vec<u8>>>
Reads one binary file through a single bounded open handle.
Sourcefn write<'a>(
&'a self,
path: &'a str,
content: &'a str,
) -> BoxFuture<'a, Result<()>>
fn write<'a>( &'a self, path: &'a str, content: &'a str, ) -> BoxFuture<'a, Result<()>>
Writes a UTF-8 file.
Sourcefn execute<'a>(
&'a self,
command: &'a str,
sandbox_mode: SandboxMode,
network_access: NetworkAccess,
mode: CommandMode,
output: CommandOutputSink,
) -> BoxFuture<'a, Result<CommandOutput>>
fn execute<'a>( &'a self, command: &'a str, sandbox_mode: SandboxMode, network_access: NetworkAccess, mode: CommandMode, output: CommandOutputSink, ) -> BoxFuture<'a, Result<CommandOutput>>
Runs a shell command and forwards drained output under the requested isolation.
Provided Methods§
Sourcefn isolated_execution(&self) -> Result<Arc<dyn SandboxBackend>>
fn isolated_execution(&self) -> Result<Arc<dyn SandboxBackend>>
Creates an independent temporary area and execution lifetime for a child agent.
Sourcefn temporary_directory(&self) -> Option<PathBuf>
fn temporary_directory(&self) -> Option<PathBuf>
Reports the private temporary path visible to command and file tools.
Sourcefn start_worker(
&self,
_command: &WorkerCommand,
_sandbox_mode: SandboxMode,
_network_access: NetworkAccess,
) -> Result<WorkerProcess>
fn start_worker( &self, _command: &WorkerCommand, _sandbox_mode: SandboxMode, _network_access: NetworkAccess, ) -> Result<WorkerProcess>
Launches a persistent framed runtime inside this backend’s execution boundary.
Sourcefn worker_connection<'a>(
&'a self,
_session_id: &'a str,
_sandbox_mode: SandboxMode,
) -> BoxFuture<'a, Result<DuplexStream>>
fn worker_connection<'a>( &'a self, _session_id: &'a str, _sandbox_mode: SandboxMode, ) -> BoxFuture<'a, Result<DuplexStream>>
Opens an authorized host-service channel for one worker evaluation. Dropping the channel ends its authority; requests are never replayed.
Runs a shell command only when authorization launches it atomically.
Backends without an atomic launch boundary fail closed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".