Skip to main content

xtask_todo_lib/devshell/vm/
session_host.rs

1//! Host-only [`super::VmExecutionSession`]: same behavior as historical `sandbox::run_rust_tool` (temp export per command).
2
3#![allow(clippy::pedantic, clippy::nursery)]
4
5use std::process::ExitStatus;
6
7use super::super::sandbox;
8use super::super::vfs::Vfs;
9use super::{VmError, VmExecutionSession};
10
11/// Runs `rustup`/`cargo` via temp directory export + sync (no persistent VM).
12#[derive(Debug, Default, Clone, Copy)]
13pub struct HostSandboxSession;
14
15impl HostSandboxSession {
16    #[must_use]
17    pub const fn new() -> Self {
18        Self
19    }
20}
21
22impl VmExecutionSession for HostSandboxSession {
23    fn ensure_ready(&mut self, _vfs: &Vfs, _vfs_cwd: &str) -> Result<(), VmError> {
24        Ok(())
25    }
26
27    fn run_rust_tool(
28        &mut self,
29        vfs: &mut Vfs,
30        vfs_cwd: &str,
31        program: &str,
32        args: &[String],
33    ) -> Result<ExitStatus, VmError> {
34        sandbox::run_rust_tool(vfs, vfs_cwd, program, args).map_err(VmError::Sandbox)
35    }
36
37    fn shutdown(&mut self, _vfs: &mut Vfs, _vfs_cwd: &str) -> Result<(), VmError> {
38        Ok(())
39    }
40}