Add new types for ProgrammingLanguageInterface

This commit is contained in:
greg 2019-03-13 00:13:39 -07:00
parent 8d8d7d8bf8
commit 5b35c2a036
2 changed files with 53 additions and 0 deletions

View File

@ -170,6 +170,48 @@ pub trait ProgrammingLanguageInterface {
fn get_doc(&self, _commands: &Vec<&str>) -> Option<String> {
None
}
/* ------- */
// new trait methods
//
//
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 repl_request(&self, repl_request: String) -> String {
format!("Repl request not implemented")
}
}
struct ComputationRequest {
pub source: String,
pub debug_requests: Vec<DebugRequest>,
}
struct ComputationResponse {
pub main_output: Result<String, String>,
pub global_output_stats: GlobalOutputStats,
pub debug_responses: Vec<DebugResponse>,
}
struct DebugRequest {
kind: String,
value: String
}
struct DebugResponse {
kind: String,
value: String
}
#[derive(Default, Debug)]
struct GlobalOutputStats {
total_duration: Option<time::Duration>,
stage_durations: Option<Vec<(String, time::Duration)>>
}

View File

@ -103,6 +103,17 @@ impl NewRepl {
}
}
/* --------------------------------------------- */
pub struct Repl {
options: EvalOptions,
languages: Vec<Box<ProgrammingLanguageInterface>>,