Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
threshold_line_style.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 ThresholdLineStyle {
17    #[serde(rename = "DOTTED")]
18    Dotted,
19    #[serde(rename = "SOLID")]
20    Solid,
21    #[serde(rename = "NONE")]
22    None,
23    /// An unknown variant.
24    #[serde(untagged)]
25    Unknown(Unknown),
26}
27impl ThresholdLineStyle {
28    /// Returns the string representation of the enum.
29    #[inline]
30    pub fn as_str(&self) -> &str {
31        match self {
32            ThresholdLineStyle::Dotted => "DOTTED",
33            ThresholdLineStyle::Solid => "SOLID",
34            ThresholdLineStyle::None => "NONE",
35            ThresholdLineStyle::Unknown(v) => &*v,
36        }
37    }
38}
39impl fmt::Display for ThresholdLineStyle {
40    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
41        fmt::Display::fmt(self.as_str(), fmt)
42    }
43}
44impl conjure_object::Plain for ThresholdLineStyle {
45    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
46        conjure_object::Plain::fmt(self.as_str(), fmt)
47    }
48}
49impl str::FromStr for ThresholdLineStyle {
50    type Err = conjure_object::plain::ParseEnumError;
51    #[inline]
52    fn from_str(
53        v: &str,
54    ) -> Result<ThresholdLineStyle, conjure_object::plain::ParseEnumError> {
55        match v {
56            "DOTTED" => Ok(ThresholdLineStyle::Dotted),
57            "SOLID" => Ok(ThresholdLineStyle::Solid),
58            "NONE" => Ok(ThresholdLineStyle::None),
59            v => v.parse().map(|v| ThresholdLineStyle::Unknown(Unknown(v))),
60        }
61    }
62}
63impl conjure_object::FromPlain for ThresholdLineStyle {
64    type Err = conjure_object::plain::ParseEnumError;
65    #[inline]
66    fn from_plain(
67        v: &str,
68    ) -> Result<ThresholdLineStyle, conjure_object::plain::ParseEnumError> {
69        v.parse()
70    }
71}
72///An unknown variant of the ThresholdLineStyle 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}