Skip to main content

nominal_api/conjure/objects/scout/run/api/
preset_timeframe_duration.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4#[derive(
5    Debug,
6    Clone,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash,
12    conjure_object::serde::Deserialize,
13    conjure_object::serde::Serialize,
14)]
15#[serde(crate = "conjure_object::serde")]
16pub enum PresetTimeframeDuration {
17    #[serde(rename = "ALL_TIME")]
18    AllTime,
19    #[serde(rename = "LAST_DAY")]
20    LastDay,
21    #[serde(rename = "LAST_WEEK")]
22    LastWeek,
23    #[serde(rename = "LAST_MONTH")]
24    LastMonth,
25    #[serde(rename = "LAST_YEAR")]
26    LastYear,
27    /// An unknown variant.
28    #[serde(untagged)]
29    Unknown(Unknown),
30}
31impl PresetTimeframeDuration {
32    /// Returns the string representation of the enum.
33    #[inline]
34    pub fn as_str(&self) -> &str {
35        match self {
36            PresetTimeframeDuration::AllTime => "ALL_TIME",
37            PresetTimeframeDuration::LastDay => "LAST_DAY",
38            PresetTimeframeDuration::LastWeek => "LAST_WEEK",
39            PresetTimeframeDuration::LastMonth => "LAST_MONTH",
40            PresetTimeframeDuration::LastYear => "LAST_YEAR",
41            PresetTimeframeDuration::Unknown(v) => &*v,
42        }
43    }
44}
45impl fmt::Display for PresetTimeframeDuration {
46    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
47        fmt::Display::fmt(self.as_str(), fmt)
48    }
49}
50impl conjure_object::Plain for PresetTimeframeDuration {
51    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
52        conjure_object::Plain::fmt(self.as_str(), fmt)
53    }
54}
55impl str::FromStr for PresetTimeframeDuration {
56    type Err = conjure_object::plain::ParseEnumError;
57    #[inline]
58    fn from_str(
59        v: &str,
60    ) -> Result<PresetTimeframeDuration, conjure_object::plain::ParseEnumError> {
61        match v {
62            "ALL_TIME" => Ok(PresetTimeframeDuration::AllTime),
63            "LAST_DAY" => Ok(PresetTimeframeDuration::LastDay),
64            "LAST_WEEK" => Ok(PresetTimeframeDuration::LastWeek),
65            "LAST_MONTH" => Ok(PresetTimeframeDuration::LastMonth),
66            "LAST_YEAR" => Ok(PresetTimeframeDuration::LastYear),
67            v => v.parse().map(|v| PresetTimeframeDuration::Unknown(Unknown(v))),
68        }
69    }
70}
71impl conjure_object::FromPlain for PresetTimeframeDuration {
72    type Err = conjure_object::plain::ParseEnumError;
73    #[inline]
74    fn from_plain(
75        v: &str,
76    ) -> Result<PresetTimeframeDuration, conjure_object::plain::ParseEnumError> {
77        v.parse()
78    }
79}
80///An unknown variant of the PresetTimeframeDuration enum.
81#[derive(
82    Debug,
83    Clone,
84    PartialEq,
85    Eq,
86    PartialOrd,
87    Ord,
88    Hash,
89    conjure_object::serde::Deserialize,
90    conjure_object::serde::Serialize,
91)]
92#[serde(crate = "conjure_object::serde", transparent)]
93pub struct Unknown(conjure_object::private::Variant);
94impl std::ops::Deref for Unknown {
95    type Target = str;
96    #[inline]
97    fn deref(&self) -> &str {
98        &self.0
99    }
100}
101impl fmt::Display for Unknown {
102    #[inline]
103    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
104        fmt::Display::fmt(&self.0, fmt)
105    }
106}