diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/mod.rs | 1 | ||||
-rw-r--r-- | src/modules/refinery.rs | 52 | ||||
-rw-r--r-- | src/modules/types.rs | 3 |
3 files changed, 55 insertions, 1 deletions
diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 0c19156..61e8133 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -2,4 +2,5 @@ pub mod mining; pub mod engines; pub mod dashboard; pub mod navigation; +pub mod refinery; pub mod types; diff --git a/src/modules/refinery.rs b/src/modules/refinery.rs new file mode 100644 index 0000000..733fcd4 --- /dev/null +++ b/src/modules/refinery.rs @@ -0,0 +1,52 @@ +use std::time::SystemTime; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct Refinery { + time : u64, + start : Option<SystemTime>, + pub status : bool, + pub ready : bool, +} + +impl Refinery { + pub fn new() -> Refinery { + Refinery { + time : 5, + start : None, + status : false, + ready : false, + } + } + + pub fn process(&mut self) { + match self.start.clone() { + Some(timer) => { + if timer.elapsed().unwrap().as_secs() > self.time { + self.start = Some(SystemTime::now()); + self.ready = true; + } + } + _ => (), + } + if !self.status { + self.start = None; + self.ready = false; + } + } + + pub fn toggle(&mut self) { + self.status = !self.status; + self.start = match self.status { + true => Some(SystemTime::now()), + false => None, + }; + } + + pub fn off(&mut self) { + self.status = false; + } + + pub fn take(&mut self) { + self.ready = false; + } +} diff --git a/src/modules/types.rs b/src/modules/types.rs index 1af99d6..48b3473 100644 --- a/src/modules/types.rs +++ b/src/modules/types.rs @@ -1,7 +1,8 @@ #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub enum ModuleType { - Navigation, Mining, Engines, + Refinery, Dashboard, + Navigation, } |