Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
threshold_shading_config.rs

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