summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/mining.rs36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/modules/mining.rs b/src/modules/mining.rs
index e22918f..7f11f05 100644
--- a/src/modules/mining.rs
+++ b/src/modules/mining.rs
@@ -6,6 +6,7 @@ pub struct Mining {
pub status : bool,
time : u64,
start : Option<SystemTime>,
+ pub ready : bool,
}
@@ -14,10 +15,41 @@ impl Mining {
Mining {
range : 10.0,
status : false,
- time : 1,
+ time : 5,
start : None,
+ ready : false,
}
}
- pub fn toggle(&self) {}
+ 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.start = Some(SystemTime::now());
+ self.ready = true;
+ }
+ }
+ _ => (),
+ }
+ if !self.status {
+ self.start = None;
+ self.ready = false;
+ }
+ }
}