Skip to main content

nominal_api_conjure/conjure/objects/api/
granularity.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    conjure_object::log_safety::derive::LogSafe
15)]
16#[serde(crate = "conjure_object::serde")]
17pub enum Granularity {
18    #[serde(rename = "NANOSECONDS")]
19    Nanoseconds,
20    /// An unknown variant.
21    #[serde(untagged)]
22    Unknown(Unknown),
23}
24impl Granularity {
25    /// Returns the string representation of the enum.
26    #[inline]
27    pub fn as_str(&self) -> &str {
28        match self {
29            Granularity::Nanoseconds => "NANOSECONDS",
30            Granularity::Unknown(v) => &*v,
31        }
32    }
33}
34impl fmt::Display for Granularity {
35    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
36        fmt::Display::fmt(self.as_str(), fmt)
37    }
38}
39impl conjure_object::Plain for Granularity {
40    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
41        conjure_object::Plain::fmt(self.as_str(), fmt)
42    }
43}
44impl str::FromStr for Granularity {
45    type Err = conjure_object::plain::ParseEnumError;
46    #[inline]
47    fn from_str(v: &str) -> Result<Granularity, conjure_object::plain::ParseEnumError> {
48        match v {
49            "NANOSECONDS" => Ok(Granularity::Nanoseconds),
50            v => v.parse().map(|v| Granularity::Unknown(Unknown(v))),
51        }
52    }
53}
54impl conjure_object::FromPlain for Granularity {
55    type Err = conjure_object::plain::ParseEnumError;
56    #[inline]
57    fn from_plain(
58        v: &str,
59    ) -> Result<Granularity, conjure_object::plain::ParseEnumError> {
60        v.parse()
61    }
62}
63///An unknown variant of the Granularity enum.
64#[derive(
65    Debug,
66    Clone,
67    PartialEq,
68    Eq,
69    PartialOrd,
70    Ord,
71    Hash,
72    conjure_object::serde::Deserialize,
73    conjure_object::serde::Serialize,
74    conjure_object::log_safety::derive::LogSafe,
75)]
76#[serde(crate = "conjure_object::serde", transparent)]
77pub struct Unknown(conjure_object::private::Variant);
78impl std::ops::Deref for Unknown {
79    type Target = str;
80    #[inline]
81    fn deref(&self) -> &str {
82        &self.0
83    }
84}
85impl fmt::Display for Unknown {
86    #[inline]
87    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
88        fmt::Display::fmt(&self.0, fmt)
89    }
90}