Skip to main content

nominal_api/conjure/objects/scout/compute/api/
unbounded_behavior.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4/// Dictates how empty range bounds should be handled by the compute node. Defaults to INFINITY.
5#[derive(
6    Debug,
7    Clone,
8    PartialEq,
9    Eq,
10    PartialOrd,
11    Ord,
12    Hash,
13    conjure_object::serde::Deserialize,
14    conjure_object::serde::Serialize,
15)]
16#[serde(crate = "conjure_object::serde")]
17pub enum UnboundedBehavior {
18    #[serde(rename = "INFINITY")]
19    Infinity,
20    #[serde(rename = "WINDOW_BOUND")]
21    WindowBound,
22    /// An unknown variant.
23    #[serde(untagged)]
24    Unknown(Unknown),
25}
26impl UnboundedBehavior {
27    /// Returns the string representation of the enum.
28    #[inline]
29    pub fn as_str(&self) -> &str {
30        match self {
31            UnboundedBehavior::Infinity => "INFINITY",
32            UnboundedBehavior::WindowBound => "WINDOW_BOUND",
33            UnboundedBehavior::Unknown(v) => &*v,
34        }
35    }
36}
37impl fmt::Display for UnboundedBehavior {
38    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
39        fmt::Display::fmt(self.as_str(), fmt)
40    }
41}
42impl conjure_object::Plain for UnboundedBehavior {
43    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
44        conjure_object::Plain::fmt(self.as_str(), fmt)
45    }
46}
47impl str::FromStr for UnboundedBehavior {
48    type Err = conjure_object::plain::ParseEnumError;
49    #[inline]
50    fn from_str(
51        v: &str,
52    ) -> Result<UnboundedBehavior, conjure_object::plain::ParseEnumError> {
53        match v {
54            "INFINITY" => Ok(UnboundedBehavior::Infinity),
55            "WINDOW_BOUND" => Ok(UnboundedBehavior::WindowBound),
56            v => v.parse().map(|v| UnboundedBehavior::Unknown(Unknown(v))),
57        }
58    }
59}
60impl conjure_object::FromPlain for UnboundedBehavior {
61    type Err = conjure_object::plain::ParseEnumError;
62    #[inline]
63    fn from_plain(
64        v: &str,
65    ) -> Result<UnboundedBehavior, conjure_object::plain::ParseEnumError> {
66        v.parse()
67    }
68}
69///An unknown variant of the UnboundedBehavior enum.
70#[derive(
71    Debug,
72    Clone,
73    PartialEq,
74    Eq,
75    PartialOrd,
76    Ord,
77    Hash,
78    conjure_object::serde::Deserialize,
79    conjure_object::serde::Serialize,
80)]
81#[serde(crate = "conjure_object::serde", transparent)]
82pub struct Unknown(conjure_object::private::Variant);
83impl std::ops::Deref for Unknown {
84    type Target = str;
85    #[inline]
86    fn deref(&self) -> &str {
87        &self.0
88    }
89}
90impl fmt::Display for Unknown {
91    #[inline]
92    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
93        fmt::Display::fmt(&self.0, fmt)
94    }
95}