use std::collections::HashSet; use std::time; pub trait ProgrammingLanguageInterface { type Options; fn language_name() -> String; fn source_file_suffix() -> String; fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse; fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse { LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!(""), } } } //TODO this is what I want /* struct Options { lang_options: T } */ pub struct ComputationRequest<'a> { pub source: &'a str, //pub options: Options<()>, pub debug_requests: HashSet, } pub struct ComputationResponse { pub main_output: Result, pub global_output_stats: GlobalOutputStats, pub debug_responses: Vec, } #[derive(Default, Debug)] pub struct GlobalOutputStats { pub total_duration: time::Duration, pub stage_durations: Vec<(String, time::Duration)>, } #[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)] pub enum DebugAsk { Timing, ByStage { stage_name: String, token: Option, }, } impl DebugAsk { pub fn is_for_stage(&self, name: &str) -> bool { match self { DebugAsk::ByStage { stage_name, .. } if stage_name == name => true, _ => false, } } } pub struct DebugResponse { pub ask: DebugAsk, pub value: String, } pub enum LangMetaRequest { StageNames, Docs { source: String }, Custom { kind: String, value: String }, ImmediateDebug(DebugAsk), } pub enum LangMetaResponse { StageNames(Vec), Docs { doc_string: String }, Custom { kind: String, value: String }, ImmediateDebug(DebugResponse), }