diff --git a/src/main.rs b/src/main.rs index afa06f7..4f27ff6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,6 @@ pub mod paths; pub mod profile; pub mod profiles; pub mod runner; -pub mod runner_pipeline; pub mod steam_linux_runtime_injector; pub mod steamvr_utils; pub mod termcolor; diff --git a/src/runner_pipeline.rs b/src/runner_pipeline.rs deleted file mode 100644 index 09e874b..0000000 --- a/src/runner_pipeline.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::runner::{Runner, RunnerStatus}; -use std::cell::RefCell; - -pub struct RunnerPipeline { - runners: Vec>>, - current_index: usize, - last_exit_status: Option, - has_started: bool, - pub log: Vec, -} - -impl RunnerPipeline { - pub fn new(runners: Vec>) -> Self { - let mut c_runners: Vec>> = vec![]; - for runner in runners { - c_runners.push(RefCell::new(runner)); - } - Self { - runners: c_runners, - current_index: 0, - has_started: false, - last_exit_status: None, - log: vec![], - } - } - - pub fn get_current_runner(&self) -> Option<&RefCell>> { - self.runners.get(self.current_index) - } - - pub fn start(&mut self) { - if self.has_started { - return; - } - self.has_started = true; - if let Some(runner) = self.get_current_runner() { - runner.borrow_mut().start(); - } - } - - pub fn update(&mut self) { - if !self.has_started { - return; - } - - match self.get_current_runner() { - None => {} - Some(c_runner) => { - let (status, log) = { - let mut runner = c_runner.borrow_mut(); - (runner.status(), runner.consume_rows()) - }; - self.log.extend(log); - match status { - RunnerStatus::Running => {} - RunnerStatus::Stopped(ecode) => { - match ecode { - None => {} // should never get here - Some(0) => { - self.last_exit_status = Some(0); - self.current_index += 1; - match self.get_current_runner() { - None => {} - Some(c_runner) => { - c_runner.borrow_mut().start(); - } - } - } - Some(nonzero) => { - self.last_exit_status = Some(nonzero); - // interrupting pipeline by going past last runner - self.current_index = self.runners.len(); - } - } - } - } - } - } - } - - pub fn get_log(&mut self) -> Vec { - let log = self.log.to_owned(); - self.log = vec![]; - log - } - - pub fn status(&self) -> RunnerStatus { - match self.get_current_runner() { - None => RunnerStatus::Stopped(self.last_exit_status), - Some(_) => RunnerStatus::Running, - } - } -}