Skip to main content

nominal_api/conjure/objects/scout/api/
priority.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 Priority {
17    #[serde(rename = "P0")]
18    P0,
19    #[serde(rename = "P1")]
20    P1,
21    #[serde(rename = "P2")]
22    P2,
23    #[serde(rename = "P3")]
24    P3,
25    #[serde(rename = "P4")]
26    P4,
27    /// An unknown variant.
28    #[serde(untagged)]
29    Unknown(Unknown),
30}
31impl Priority {
32    /// Returns the string representation of the enum.
33    #[inline]
34    pub fn as_str(&self) -> &str {
35        match self {
36            Priority::P0 => "P0",
37            Priority::P1 => "P1",
38            Priority::P2 => "P2",
39            Priority::P3 => "P3",
40            Priority::P4 => "P4",
41            Priority::Unknown(v) => &*v,
42        }
43    }
44}
45impl fmt::Display for Priority {
46    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
47        fmt::Display::fmt(self.as_str(), fmt)
48    }
49}
50impl conjure_object::Plain for Priority {
51    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
52        conjure_object::Plain::fmt(self.as_str(), fmt)
53    }
54}
55impl str::FromStr for Priority {
56    type Err = conjure_object::plain::ParseEnumError;
57    #[inline]
58    fn from_str(v: &str) -> Result<Priority, conjure_object::plain::ParseEnumError> {
59        match v {
60            "P0" => Ok(Priority::P0),
61            "P1" => Ok(Priority::P1),
62            "P2" => Ok(Priority::P2),
63            "P3" => Ok(Priority::P3),
64            "P4" => Ok(Priority::P4),
65            v => v.parse().map(|v| Priority::Unknown(Unknown(v))),
66        }
67    }
68}
69impl conjure_object::FromPlain for Priority {
70    type Err = conjure_object::plain::ParseEnumError;
71    #[inline]
72    fn from_plain(v: &str) -> Result<Priority, conjure_object::plain::ParseEnumError> {
73        v.parse()
74    }
75}
76///An unknown variant of the Priority 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}