eb2adb5b79
Showing time
75 lines
1.6 KiB
Rust
75 lines
1.6 KiB
Rust
use std::time;
|
|
|
|
pub trait ProgrammingLanguageInterface {
|
|
fn get_language_name(&self) -> String;
|
|
fn get_source_file_suffix(&self) -> String;
|
|
|
|
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![],
|
|
}
|
|
}
|
|
|
|
fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse {
|
|
LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!("") }
|
|
}
|
|
}
|
|
|
|
pub struct ComputationRequest<'a> {
|
|
pub source: &'a str,
|
|
pub debug_requests: Vec<DebugRequest>,
|
|
}
|
|
|
|
pub struct ComputationResponse {
|
|
pub main_output: Result<String, String>,
|
|
pub global_output_stats: GlobalOutputStats,
|
|
pub debug_responses: Vec<DebugResponse>,
|
|
}
|
|
|
|
#[derive(Default, Debug)]
|
|
pub struct GlobalOutputStats {
|
|
pub total_duration: time::Duration,
|
|
pub stage_durations: Option<Vec<(String, time::Duration)>>
|
|
}
|
|
|
|
pub struct DebugRequest {
|
|
pub ask: DebugAsk,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
|
pub enum DebugAsk {
|
|
Timing,
|
|
ByStage { stage_name: String },
|
|
}
|
|
|
|
pub struct DebugResponse {
|
|
pub ask: DebugAsk,
|
|
pub value: String
|
|
}
|
|
|
|
pub enum LangMetaRequest {
|
|
StageNames,
|
|
Docs {
|
|
source: String,
|
|
},
|
|
Custom {
|
|
kind: String,
|
|
value: String
|
|
},
|
|
ImmediateDebug(DebugRequest),
|
|
}
|
|
|
|
pub enum LangMetaResponse {
|
|
StageNames(Vec<String>),
|
|
Docs {
|
|
doc_string: String,
|
|
},
|
|
Custom {
|
|
kind: String,
|
|
value: String
|
|
},
|
|
ImmediateDebug(DebugResponse),
|
|
}
|