fitnesstrax_lib/types/
repduration.rs1use dimensioned::si::Second;
2use emseries::{DateTimeTz, Recordable};
3
4#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
5pub enum ActivityType {
6 MartialArts,
7 Planks,
8 Yoga,
9}
10
11#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
12pub struct RepDurationRecord {
13 #[serde(rename = "date")]
14 timestamp: DateTimeTz,
15 pub activity: ActivityType,
16 pub sets: Vec<Second<f64>>,
17 pub comments: Option<String>,
18}
19
20impl RepDurationRecord {
21 pub fn new(
22 timestamp: DateTimeTz,
23 activity: ActivityType,
24 sets: Vec<Second<f64>>,
25 comments: Option<String>,
26 ) -> RepDurationRecord {
27 RepDurationRecord {
28 timestamp,
29 activity,
30 sets,
31 comments,
32 }
33 }
34}
35
36impl Recordable for RepDurationRecord {
37 fn timestamp(&self) -> DateTimeTz {
38 self.timestamp.clone()
39 }
40
41 fn tags(&self) -> Vec<String> {
42 match self.activity {
43 ActivityType::MartialArts => vec![String::from("MartialArts")],
44 ActivityType::Planks => vec![String::from("Planks")],
45 ActivityType::Yoga => vec![String::from("Yoga")],
46 }
47 }
48}