aboutsummaryrefslogtreecommitdiff
path: root/src/habit/bit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/habit/bit.rs')
-rw-r--r--src/habit/bit.rs25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/habit/bit.rs b/src/habit/bit.rs
index 2bbb0ac..da64ece 100644
--- a/src/habit/bit.rs
+++ b/src/habit/bit.rs
@@ -1,11 +1,12 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2use std::default::Default;
2 3
3use chrono::NaiveDate; 4use chrono::NaiveDate;
4use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
5 6
6use crate::habit::prelude::default_auto; 7use crate::habit::prelude::default_auto;
7use crate::habit::traits::Habit; 8use crate::habit::traits::Habit;
8use crate::habit::{TrackEvent, ViewMode}; 9use crate::habit::{InnerData, TrackEvent};
9use crate::CONFIGURATION; 10use crate::CONFIGURATION;
10 11
11#[derive(Copy, Clone, Debug, Serialize, Deserialize)] 12#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
@@ -42,10 +43,7 @@ pub struct Bit {
42 auto: bool, 43 auto: bool,
43 44
44 #[serde(skip)] 45 #[serde(skip)]
45 view_month_offset: u32, 46 inner_data: InnerData,
46
47 #[serde(skip)]
48 view_mode: ViewMode,
49} 47}
50 48
51impl Bit { 49impl Bit {
@@ -55,8 +53,7 @@ impl Bit {
55 stats: HashMap::new(), 53 stats: HashMap::new(),
56 goal: CustomBool(true), 54 goal: CustomBool(true),
57 auto, 55 auto,
58 view_month_offset: 0, 56 inner_data: Default::default(),
59 view_mode: ViewMode::Day,
60 }; 57 };
61 } 58 }
62} 59}
@@ -118,17 +115,11 @@ impl Habit for Bit {
118 } 115 }
119 } 116 }
120 } 117 }
121 fn set_view_month_offset(&mut self, offset: u32) { 118 fn inner_data_ref(&self) -> &InnerData {
122 self.view_month_offset = offset; 119 &self.inner_data
123 }
124 fn view_month_offset(&self) -> u32 {
125 self.view_month_offset
126 }
127 fn set_view_mode(&mut self, mode: ViewMode) {
128 self.view_mode = mode;
129 } 120 }
130 fn view_mode(&self) -> ViewMode { 121 fn inner_data_mut_ref(&mut self) -> &mut InnerData {
131 self.view_mode 122 &mut self.inner_data
132 } 123 }
133 fn is_auto(&self) -> bool { 124 fn is_auto(&self) -> bool {
134 self.auto 125 self.auto