2019-05-26 04:16:40 -07:00
|
|
|
use std::collections::HashSet;
|
2021-10-07 01:19:35 -07:00
|
|
|
use std::time;
|
2017-09-08 03:47:04 -07:00
|
|
|
|
2017-08-30 19:09:22 -07:00
|
|
|
pub trait ProgrammingLanguageInterface {
|
2021-10-14 02:24:42 -07:00
|
|
|
type Config: Default;
|
2021-10-14 00:56:01 -07:00
|
|
|
fn language_name() -> String;
|
|
|
|
fn source_file_suffix() -> String;
|
2019-03-13 00:13:39 -07:00
|
|
|
|
2021-10-14 02:24:42 -07:00
|
|
|
fn run_computation(&mut self, _request: ComputationRequest<Self::Config>) -> ComputationResponse;
|
2019-03-13 00:13:39 -07:00
|
|
|
|
2021-10-07 01:19:35 -07:00
|
|
|
fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse {
|
|
|
|
LangMetaResponse::Custom {
|
2021-10-14 02:08:32 -07:00
|
|
|
kind: "not-implemented".to_owned(),
|
2021-10-07 01:19:35 -07:00
|
|
|
value: format!(""),
|
|
|
|
}
|
|
|
|
}
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
|
2021-10-14 02:24:42 -07:00
|
|
|
pub struct ComputationRequest<'a, T> {
|
2021-10-07 01:19:35 -07:00
|
|
|
pub source: &'a str,
|
2021-10-14 02:24:42 -07:00
|
|
|
pub config: T,
|
2021-10-07 01:19:35 -07:00
|
|
|
pub debug_requests: HashSet<DebugAsk>,
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct ComputationResponse {
|
2021-10-07 01:19:35 -07:00
|
|
|
pub main_output: Result<String, String>,
|
|
|
|
pub global_output_stats: GlobalOutputStats,
|
|
|
|
pub debug_responses: Vec<DebugResponse>,
|
2017-08-30 19:09:22 -07:00
|
|
|
}
|
2019-03-12 00:01:30 -07:00
|
|
|
|
2019-05-21 02:06:34 -07:00
|
|
|
#[derive(Default, Debug)]
|
|
|
|
pub struct GlobalOutputStats {
|
2021-10-07 01:19:35 -07:00
|
|
|
pub total_duration: time::Duration,
|
|
|
|
pub stage_durations: Vec<(String, time::Duration)>,
|
2019-05-21 02:06:34 -07:00
|
|
|
}
|
|
|
|
|
2019-05-14 00:40:38 -07:00
|
|
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
2019-03-31 01:13:40 -07:00
|
|
|
pub enum DebugAsk {
|
2021-10-07 01:19:35 -07:00
|
|
|
Timing,
|
|
|
|
ByStage {
|
|
|
|
stage_name: String,
|
|
|
|
token: Option<String>,
|
|
|
|
},
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
2019-03-12 00:01:30 -07:00
|
|
|
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct DebugResponse {
|
2021-10-07 01:19:35 -07:00
|
|
|
pub ask: DebugAsk,
|
|
|
|
pub value: String,
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:12:32 -07:00
|
|
|
pub enum LangMetaRequest {
|
2021-10-07 01:19:35 -07:00
|
|
|
StageNames,
|
|
|
|
Docs { source: String },
|
|
|
|
Custom { kind: String, value: String },
|
|
|
|
ImmediateDebug(DebugAsk),
|
2019-03-19 19:12:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub enum LangMetaResponse {
|
2021-10-07 01:19:35 -07:00
|
|
|
StageNames(Vec<String>),
|
|
|
|
Docs { doc_string: String },
|
|
|
|
Custom { kind: String, value: String },
|
|
|
|
ImmediateDebug(DebugResponse),
|
2019-03-19 19:12:32 -07:00
|
|
|
}
|