mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-31 13:18:46 +00:00
feat: remove unnecessary runner trait
This commit is contained in:
parent
12281a25b5
commit
8fb9e1c1f1
4 changed files with 10 additions and 22 deletions
|
@ -1,6 +1,5 @@
|
|||
use crate::{
|
||||
profile::{Profile, XRServiceType},
|
||||
runner::{Runner, RunnerStatus},
|
||||
util::file_utils::get_writer,
|
||||
};
|
||||
use nix::{
|
||||
|
@ -23,6 +22,12 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum RunnerStatus {
|
||||
Running,
|
||||
Stopped(Option<i32>),
|
||||
}
|
||||
|
||||
pub struct CmdRunner {
|
||||
pub environment: HashMap<String, String>,
|
||||
pub command: String,
|
||||
|
@ -182,24 +187,22 @@ impl CmdRunner {
|
|||
pub fn save_output(&mut self, path: &Path) -> Result<(), std::io::Error> {
|
||||
CmdRunner::save_log(path, &self.output)
|
||||
}
|
||||
}
|
||||
|
||||
impl Runner for CmdRunner {
|
||||
fn consume_output(&mut self) -> String {
|
||||
pub fn consume_output(&mut self) -> String {
|
||||
self.receive_output();
|
||||
let res = self.output.concat();
|
||||
self.output.clear();
|
||||
res
|
||||
}
|
||||
|
||||
fn consume_rows(&mut self) -> Vec<String> {
|
||||
pub fn consume_rows(&mut self) -> Vec<String> {
|
||||
self.receive_output();
|
||||
let res = self.output.clone();
|
||||
self.output.clear();
|
||||
res
|
||||
}
|
||||
|
||||
fn status(&mut self) -> RunnerStatus {
|
||||
pub fn status(&mut self) -> RunnerStatus {
|
||||
match &mut self.process {
|
||||
None => RunnerStatus::Stopped(None),
|
||||
Some(proc) => match proc.try_wait() {
|
||||
|
@ -210,7 +213,7 @@ impl Runner for CmdRunner {
|
|||
}
|
||||
}
|
||||
|
||||
fn start(&mut self) {
|
||||
pub fn start(&mut self) {
|
||||
self.try_start().expect("Failed to execute runner");
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +222,6 @@ impl Runner for CmdRunner {
|
|||
mod tests {
|
||||
use super::{CmdRunner, RunnerStatus};
|
||||
use crate::profile::Profile;
|
||||
use crate::runner::Runner;
|
||||
use core::time;
|
||||
use std::{path::Path, thread::sleep};
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ pub mod openxr_prober;
|
|||
pub mod paths;
|
||||
pub mod profile;
|
||||
pub mod profiles;
|
||||
pub mod runner;
|
||||
pub mod steam_linux_runtime_injector;
|
||||
pub mod steamvr_utils;
|
||||
pub mod termcolor;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum RunnerStatus {
|
||||
Running,
|
||||
Stopped(Option<i32>),
|
||||
}
|
||||
|
||||
pub trait Runner {
|
||||
fn start(&mut self);
|
||||
fn status(&mut self) -> RunnerStatus;
|
||||
fn consume_output(&mut self) -> String;
|
||||
fn consume_rows(&mut self) -> Vec<String>;
|
||||
}
|
|
@ -2,7 +2,6 @@ use super::alert::alert;
|
|||
use crate::{
|
||||
cmd_runner::CmdRunner,
|
||||
profile::{prepare_ld_library_path, Profile},
|
||||
runner::Runner,
|
||||
};
|
||||
use adw::prelude::*;
|
||||
use gtk::glib;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue