twapi_v2/fields/
usage_fields.rs

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
use serde::{Deserialize, Serialize};
use std::collections::HashSet;

#[derive(Serialize, Deserialize, Debug, Eq, Hash, PartialEq, Clone)]
pub enum UsageFields {
    #[serde(rename = "daily_client_app_usage")]
    DailyClientAppUsage,
    #[serde(rename = "daily_project_usage")]
    DailyProjectUsage,
}

impl UsageFields {
    pub fn all() -> HashSet<Self> {
        let mut result = HashSet::new();
        result.insert(Self::DailyClientAppUsage);
        result.insert(Self::DailyProjectUsage);
        result
    }
}

impl std::fmt::Display for UsageFields {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            Self::DailyClientAppUsage => write!(f, "daily_client_app_usage"),
            Self::DailyProjectUsage => write!(f, "daily_project_usage"),
        }
    }
}

impl Default for UsageFields {
    fn default() -> Self {
        Self::DailyClientAppUsage
    }
}