2021-11-24 23:51:30 -08:00
|
|
|
use std::{collections::HashSet, time};
|
2017-09-08 03:47:04 -07:00
|
|
|
|
2017-08-30 19:09:22 -07:00
|
|
|
pub trait ProgrammingLanguageInterface {
|
2021-10-31 03:30:45 -07:00
|
|
|
type Config: Default + Clone;
|
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 {
|
2021-11-24 23:51:30 -08:00
|
|
|
LangMetaResponse::Custom { kind: "not-implemented".to_owned(), value: format!("") }
|
2021-10-07 01:19:35 -07:00
|
|
|
}
|
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,
|
2021-11-24 23:51:30 -08: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 {
|
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
|
|
|
}
|