summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/mining.rs57
-rw-r--r--src/modules/mod.rs4
-rw-r--r--src/modules/refinery.rs35
3 files changed, 57 insertions, 39 deletions
diff --git a/src/modules/mining.rs b/src/modules/mining.rs
index 7f11f05..4a1a37f 100644
--- a/src/modules/mining.rs
+++ b/src/modules/mining.rs
@@ -1,55 +1,64 @@
use std::time::SystemTime;
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
+pub enum MiningStatus {
+ None,
+ Mining,
+ Mined,
+}
+
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Mining {
pub range : f64,
- pub status : bool,
+ pub status : MiningStatus,
time : u64,
start : Option<SystemTime>,
- pub ready : bool,
}
-
impl Mining {
pub fn new() -> Mining {
Mining {
range : 10.0,
- status : false,
+ status : MiningStatus::None,
time : 5,
start : None,
- 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;
- }
-
pub fn process(&mut self) {
match self.start.clone() {
Some(timer) => {
if timer.elapsed().unwrap().as_secs() > self.time {
+ self.status = MiningStatus::Mined;
self.start = Some(SystemTime::now());
- self.ready = true;
}
}
_ => (),
}
- if !self.status {
+ if self.status == MiningStatus::None {
self.start = None;
- self.ready = false;
}
}
+
+ pub fn toggle(&mut self) {
+ self.status = match self.status {
+ MiningStatus::None => {
+ self.start = Some(SystemTime::now());
+ MiningStatus::Mining
+ }
+ _ => {
+ self.start = None;
+ MiningStatus::None
+ }
+ };
+ }
+
+ pub fn off(&mut self) {
+ self.status = MiningStatus::None;
+ }
+
+ pub fn take(&mut self) {
+ self.status = MiningStatus::Mining;
+ }
+
}
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
index 61e8133..18cba81 100644
--- a/src/modules/mod.rs
+++ b/src/modules/mod.rs
@@ -1,6 +1,6 @@
+pub mod types;
pub mod mining;
pub mod engines;
+pub mod refinery;
pub mod dashboard;
pub mod navigation;
-pub mod refinery;
-pub mod types;
diff --git a/src/modules/refinery.rs b/src/modules/refinery.rs
index 733fcd4..177f2c5 100644
--- a/src/modules/refinery.rs
+++ b/src/modules/refinery.rs
@@ -1,11 +1,17 @@
use std::time::SystemTime;
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
+pub enum RefineryStatus {
+ None,
+ Refining,
+ Refined,
+}
+
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Refinery {
time : u64,
start : Option<SystemTime>,
- pub status : bool,
- pub ready : bool,
+ pub status : RefineryStatus,
}
impl Refinery {
@@ -13,8 +19,7 @@ impl Refinery {
Refinery {
time : 5,
start : None,
- status : false,
- ready : false,
+ status : RefineryStatus::None,
}
}
@@ -22,31 +27,35 @@ impl Refinery {
match self.start.clone() {
Some(timer) => {
if timer.elapsed().unwrap().as_secs() > self.time {
+ self.status = RefineryStatus::Refined;
self.start = Some(SystemTime::now());
- self.ready = true;
}
}
_ => (),
}
- if !self.status {
+ if self.status == RefineryStatus::None {
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,
+ self.status = match self.status {
+ RefineryStatus::None => {
+ self.start = Some(SystemTime::now());
+ RefineryStatus::Refining
+ },
+ _ => {
+ self.start = None;
+ RefineryStatus::None
+ }
};
}
pub fn off(&mut self) {
- self.status = false;
+ self.status = RefineryStatus::None;
}
pub fn take(&mut self) {
- self.ready = false;
+ self.status = RefineryStatus::Refining;
}
}