1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
use serde::Deserialize;
use serde::Serialize;
pub fn running_template() -> TemplateSpec {
TemplateSpec::Table(vec![
Column {
display_name: Some("Date".to_string()),
field: FieldSpec::App(
Function::DisplayUnit(Unit::Timestamp, "date".to_string()),
vec![FieldSpec::Field("start_time".to_string())],
),
},
Column {
display_name: Some("Time".to_string()),
field: FieldSpec::App(
Function::DisplayUnit(Unit::Seconds, "".to_string()),
vec![FieldSpec::Field("moving_time".to_string())],
),
},
Column {
display_name: Some("Distance".to_string()),
field: FieldSpec::App(
Function::DisplayUnit(Unit::Meters, "miles".to_string()),
vec![FieldSpec::Field("distance".to_string())],
),
},
Column {
display_name: Some("Pace".to_string()),
field: FieldSpec::App(
Function::DisplayUnit(Unit::Pace, "".to_string()),
vec![FieldSpec::App(
Function::Div,
vec![
FieldSpec::Field("moving_time".to_string()),
FieldSpec::Field("distance".to_string()),
],
)],
),
},
])
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Unit {
Timestamp, // As Rfc3339
Meters,
Seconds,
Speed, // As m/s
Pace, // As s/m
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Function {
TimestampToDate,
DisplayUnit(Unit, String),
Div,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum FieldSpec {
Field(String),
App(Function, Vec<FieldSpec>),
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Column {
display_name: Option<String>,
field: FieldSpec,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum TemplateSpec {
Table(Vec<Column>),
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Template {
pub entry_type: String,
pub spec: TemplateSpec,
}
|