57 lines
1.5 KiB
Rust
57 lines
1.5 KiB
Rust
use std::{collections::HashSet, time};
|
|
|
|
pub trait ProgrammingLanguageInterface {
|
|
type Config: Default + Clone;
|
|
fn language_name() -> String;
|
|
fn source_file_suffix() -> String;
|
|
|
|
fn run_computation(&mut self, _request: ComputationRequest<Self::Config>) -> ComputationResponse;
|
|
|
|
fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse {
|
|
LangMetaResponse::Custom { kind: "not-implemented".to_owned(), value: format!("") }
|
|
}
|
|
}
|
|
|
|
pub struct ComputationRequest<'a, T> {
|
|
pub source: &'a str,
|
|
pub config: T,
|
|
pub debug_requests: HashSet<DebugAsk>,
|
|
}
|
|
|
|
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: Vec<(String, time::Duration)>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
|
pub enum DebugAsk {
|
|
Timing,
|
|
ByStage { stage_name: String, token: Option<String> },
|
|
}
|
|
|
|
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<String>),
|
|
Docs { doc_string: String },
|
|
Custom { kind: String, value: String },
|
|
ImmediateDebug(DebugResponse),
|
|
}
|