Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
floating_legend_preset_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 FloatingLegendPresetPosition {
17    #[serde(rename = "TOP_LEFT")]
18    TopLeft,
19    #[serde(rename = "TOP_RIGHT")]
20    TopRight,
21    #[serde(rename = "BOTTOM_LEFT")]
22    BottomLeft,
23    #[serde(rename = "BOTTOM_RIGHT")]
24    BottomRight,
25    /// An unknown variant.
26    #[serde(untagged)]
27    Unknown(Unknown),
28}
29impl FloatingLegendPresetPosition {
30    /// Returns the string representation of the enum.
31    #[inline]
32    pub fn as_str(&self) -> &str {
33        match self {
34            FloatingLegendPresetPosition::TopLeft => "TOP_LEFT",
35            FloatingLegendPresetPosition::TopRight => "TOP_RIGHT",
36            FloatingLegendPresetPosition::BottomLeft => "BOTTOM_LEFT",
37            FloatingLegendPresetPosition::BottomRight => "BOTTOM_RIGHT",
38            FloatingLegendPresetPosition::Unknown(v) => &*v,
39        }
40    }
41}
42impl fmt::Display for FloatingLegendPresetPosition {
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 FloatingLegendPresetPosition {
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 FloatingLegendPresetPosition {
53    type Err = conjure_object::plain::ParseEnumError;
54    #[inline]
55    fn from_str(
56        v: &str,
57    ) -> Result<FloatingLegendPresetPosition, conjure_object::plain::ParseEnumError> {
58        match v {
59            "TOP_LEFT" => Ok(FloatingLegendPresetPosition::TopLeft),
60            "TOP_RIGHT" => Ok(FloatingLegendPresetPosition::TopRight),
61            "BOTTOM_LEFT" => Ok(FloatingLegendPresetPosition::BottomLeft),
62            "BOTTOM_RIGHT" => Ok(FloatingLegendPresetPosition::BottomRight),
63            v => v.parse().map(|v| FloatingLegendPresetPosition::Unknown(Unknown(v))),
64        }
65    }
66}
67impl conjure_object::FromPlain for FloatingLegendPresetPosition {
68    type Err = conjure_object::plain::ParseEnumError;
69    #[inline]
70    fn from_plain(
71        v: &str,
72    ) -> Result<FloatingLegendPresetPosition, conjure_object::plain::ParseEnumError> {
73        v.parse()
74    }
75}
76///An unknown variant of the FloatingLegendPresetPosition 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}