Skip to main content

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