2018-08-14 22:56:22 -07:00
|
|
|
use std::time;
|
2019-05-26 04:16:40 -07:00
|
|
|
use std::collections::HashSet;
|
2017-09-08 03:47:04 -07:00
|
|
|
|
2017-08-30 19:09:22 -07:00
|
|
|
pub trait ProgrammingLanguageInterface {
|
|
|
|
fn get_language_name(&self) -> String;
|
2017-10-02 23:07:05 -07:00
|
|
|
fn get_source_file_suffix(&self) -> String;
|
2019-03-13 00:13:39 -07:00
|
|
|
|
|
|
|
fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse {
|
|
|
|
ComputationResponse {
|
|
|
|
main_output: Err(format!("Computation pipeline not implemented")),
|
|
|
|
global_output_stats: GlobalOutputStats::default(),
|
|
|
|
debug_responses: vec![],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 19:12:32 -07:00
|
|
|
fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse {
|
|
|
|
LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!("") }
|
|
|
|
}
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:01:04 -07:00
|
|
|
pub struct ComputationRequest<'a> {
|
|
|
|
pub source: &'a str,
|
2019-05-26 04:16:40 -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 {
|
2019-03-13 00:13:39 -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 {
|
2019-05-21 02:46:07 -07:00
|
|
|
pub total_duration: time::Duration,
|
2019-05-25 20:09:11 -07:00
|
|
|
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 {
|
|
|
|
Timing,
|
2019-06-19 03:27:18 -07:00
|
|
|
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 {
|
2019-03-31 01:13:40 -07:00
|
|
|
pub ask: DebugAsk,
|
2019-03-27 02:20:43 -07:00
|
|
|
pub value: String
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
|
2019-03-19 19:12:32 -07:00
|
|
|
pub enum LangMetaRequest {
|
|
|
|
StageNames,
|
2019-03-19 19:26:05 -07:00
|
|
|
Docs {
|
|
|
|
source: String,
|
|
|
|
},
|
2019-03-19 19:12:32 -07:00
|
|
|
Custom {
|
|
|
|
kind: String,
|
|
|
|
value: String
|
2019-03-27 02:20:43 -07:00
|
|
|
},
|
2019-05-25 19:31:41 -07:00
|
|
|
ImmediateDebug(DebugAsk),
|
2019-03-19 19:12:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub enum LangMetaResponse {
|
|
|
|
StageNames(Vec<String>),
|
2019-03-19 19:26:05 -07:00
|
|
|
Docs {
|
|
|
|
doc_string: String,
|
|
|
|
},
|
2019-03-19 19:12:32 -07:00
|
|
|
Custom {
|
|
|
|
kind: String,
|
|
|
|
value: String
|
2019-03-27 02:20:43 -07:00
|
|
|
},
|
|
|
|
ImmediateDebug(DebugResponse),
|
2019-03-19 19:12:32 -07:00
|
|
|
}
|