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
// Implements the various operations for `MetricTypes`

/// These represent the possible operations that
/// can be applied to a time series
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum Ops {
    /// These are operations that are performed
    /// on two time series and return one.
    Multiply,
    Add,
    Subtract,
    Divive,
    Merge,

    /// These are operations that are performed 
    /// on one time series and return one 
    Sqrt,
    Square,
    Variance,
    StdDeviation,

    /// These are operations that are performed 
    /// on one time series and return one time 
    /// series of a lower cardinality.
    Rate(Interval),
    Sum(Interval),
    Max(Interval),
    Min(Interval),
}

/// An `Interval` represents a period of time in seconds.
/// This is not a type in `chrono` as `chrono::Duration` 
/// does not support `serde` yet.
pub type Interval = i64;