Skip to main content

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