Skip to main content

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