use super::{input_translate, output_translate};
use crate::runtimes::{CommandVm, CommandVmRuntime};
use anyhow::Result;
use nar_dev_utils::manipulate;
use navm::vm::VmLauncher;
use std::path::PathBuf;
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NARSPython {
exe_path: PathBuf,
}
impl NARSPython {
pub fn new(exe_path: impl Into<PathBuf>) -> Self {
Self {
exe_path: exe_path.into(),
}
}
}
impl VmLauncher for NARSPython {
type Runtime = CommandVmRuntime;
fn launch(self) -> Result<CommandVmRuntime> {
manipulate!(
CommandVm::new(self.exe_path)
=> .input_translator(input_translate)
=> .output_translator(output_translate)
)
.launch()
}
}