mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 06:38:52 +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::{
|
use crate::{
|
||||||
profile::{Profile, XRServiceType},
|
profile::{Profile, XRServiceType},
|
||||||
runner::{Runner, RunnerStatus},
|
|
||||||
util::file_utils::get_writer,
|
util::file_utils::get_writer,
|
||||||
};
|
};
|
||||||
use nix::{
|
use nix::{
|
||||||
|
@ -23,6 +22,12 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq, Debug)]
|
||||||
|
pub enum RunnerStatus {
|
||||||
|
Running,
|
||||||
|
Stopped(Option<i32>),
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CmdRunner {
|
pub struct CmdRunner {
|
||||||
pub environment: HashMap<String, String>,
|
pub environment: HashMap<String, String>,
|
||||||
pub command: String,
|
pub command: String,
|
||||||
|
@ -182,24 +187,22 @@ impl CmdRunner {
|
||||||
pub fn save_output(&mut self, path: &Path) -> Result<(), std::io::Error> {
|
pub fn save_output(&mut self, path: &Path) -> Result<(), std::io::Error> {
|
||||||
CmdRunner::save_log(path, &self.output)
|
CmdRunner::save_log(path, &self.output)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Runner for CmdRunner {
|
pub fn consume_output(&mut self) -> String {
|
||||||
fn consume_output(&mut self) -> String {
|
|
||||||
self.receive_output();
|
self.receive_output();
|
||||||
let res = self.output.concat();
|
let res = self.output.concat();
|
||||||
self.output.clear();
|
self.output.clear();
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_rows(&mut self) -> Vec<String> {
|
pub fn consume_rows(&mut self) -> Vec<String> {
|
||||||
self.receive_output();
|
self.receive_output();
|
||||||
let res = self.output.clone();
|
let res = self.output.clone();
|
||||||
self.output.clear();
|
self.output.clear();
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn status(&mut self) -> RunnerStatus {
|
pub fn status(&mut self) -> RunnerStatus {
|
||||||
match &mut self.process {
|
match &mut self.process {
|
||||||
None => RunnerStatus::Stopped(None),
|
None => RunnerStatus::Stopped(None),
|
||||||
Some(proc) => match proc.try_wait() {
|
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");
|
self.try_start().expect("Failed to execute runner");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +222,6 @@ impl Runner for CmdRunner {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{CmdRunner, RunnerStatus};
|
use super::{CmdRunner, RunnerStatus};
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
use crate::runner::Runner;
|
|
||||||
use core::time;
|
use core::time;
|
||||||
use std::{path::Path, thread::sleep};
|
use std::{path::Path, thread::sleep};
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ pub mod openxr_prober;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
pub mod profiles;
|
pub mod profiles;
|
||||||
pub mod runner;
|
|
||||||
pub mod steam_linux_runtime_injector;
|
pub mod steam_linux_runtime_injector;
|
||||||
pub mod steamvr_utils;
|
pub mod steamvr_utils;
|
||||||
pub mod termcolor;
|
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::{
|
use crate::{
|
||||||
cmd_runner::CmdRunner,
|
cmd_runner::CmdRunner,
|
||||||
profile::{prepare_ld_library_path, Profile},
|
profile::{prepare_ld_library_path, Profile},
|
||||||
runner::Runner,
|
|
||||||
};
|
};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue