Skip to main content

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