use super::{input_translate, output_translate};
use crate::{
cin_implements::common::CommandGeneratorJulia,
runtimes::{CommandGenerator, CommandVm, CommandVmRuntime},
};
use anyhow::Result;
use nar_dev_utils::manipulate;
use navm::vm::VmLauncher;
use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct OpenJunars {
command_generator: CommandGeneratorJulia,
}
impl OpenJunars {
pub fn new(jl_path: impl Into<PathBuf>) -> Self {
Self {
command_generator: CommandGeneratorJulia::new(jl_path),
}
}
}
impl VmLauncher for OpenJunars {
type Runtime = CommandVmRuntime;
fn launch(self) -> Result<CommandVmRuntime> {
let command = self.command_generator.generate_command();
manipulate!(
CommandVm::from(command)
=> .input_translator(input_translate)
=> .output_translator(output_translate)
)
.launch()
}
}