Skip to main content

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