use crate::executor::{javascript::NodeJSExecutor, php::PhpExecutor, python::PythonExecutor}; pub mod javascript; pub mod php; pub mod python; pub mod helper; pub fn executors() -> Vec> { vec![ Box::new(NodeJSExecutor {}), Box::new(PhpExecutor {}), Box::new(PythonExecutor {}), ] } pub fn executors_id() -> Vec { executors() .iter() .map(|x| x.id()) .collect() } pub fn get_executor<'a, T: Into>(id: T, executors: &'a Vec>) -> Option<&'a Box> { let id: String = id.into(); let found = executors.iter().find(|x| x.id() == id); found } pub trait Executor { fn id(&self) -> String; fn exec(&self, code: String) -> Result; }