30 lines
640 B
Rust
30 lines
640 B
Rust
|
use crate::executor::python::PythonExecutor;
|
||
|
|
||
|
|
||
|
pub mod python;
|
||
|
pub mod helper;
|
||
|
|
||
|
pub fn executors() -> Vec<Box<dyn Executor>> {
|
||
|
vec![
|
||
|
Box::new(PythonExecutor {}),
|
||
|
|
||
|
]
|
||
|
}
|
||
|
|
||
|
pub fn executors_id() -> Vec<String> {
|
||
|
executors()
|
||
|
.iter()
|
||
|
.map(|x| x.id())
|
||
|
.collect()
|
||
|
}
|
||
|
|
||
|
pub fn get_executor<'a, T: Into<String>>(id: T, executors: &'a Vec<Box<dyn Executor>>) -> Option<&'a Box<dyn Executor>> {
|
||
|
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<String, String>;
|
||
|
}
|