Skip to main content

nominal_api_conjure/conjure/objects/api/
channel_kind.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4/// Classifies how a channel is used. COMMAND channels accept commands through the Command Service.
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    conjure_object::log_safety::derive::LogSafe
16)]
17#[serde(crate = "conjure_object::serde")]
18pub enum ChannelKind {
19    #[serde(rename = "STANDARD")]
20    Standard,
21    #[serde(rename = "COMMAND")]
22    Command,
23    /// An unknown variant.
24    #[serde(untagged)]
25    Unknown(Unknown),
26}
27impl ChannelKind {
28    /// Returns the string representation of the enum.
29    #[inline]
30    pub fn as_str(&self) -> &str {
31        match self {
32            ChannelKind::Standard => "STANDARD",
33            ChannelKind::Command => "COMMAND",
34            ChannelKind::Unknown(v) => &*v,
35        }
36    }
37}
38impl fmt::Display for ChannelKind {
39    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
40        fmt::Display::fmt(self.as_str(), fmt)
41    }
42}
43impl conjure_object::Plain for ChannelKind {
44    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
45        conjure_object::Plain::fmt(self.as_str(), fmt)
46    }
47}
48impl str::FromStr for ChannelKind {
49    type Err = conjure_object::plain::ParseEnumError;
50    #[inline]
51    fn from_str(v: &str) -> Result<ChannelKind, conjure_object::plain::ParseEnumError> {
52        match v {
53            "STANDARD" => Ok(ChannelKind::Standard),
54            "COMMAND" => Ok(ChannelKind::Command),
55            v => v.parse().map(|v| ChannelKind::Unknown(Unknown(v))),
56        }
57    }
58}
59impl conjure_object::FromPlain for ChannelKind {
60    type Err = conjure_object::plain::ParseEnumError;
61    #[inline]
62    fn from_plain(
63        v: &str,
64    ) -> Result<ChannelKind, conjure_object::plain::ParseEnumError> {
65        v.parse()
66    }
67}
68///An unknown variant of the ChannelKind enum.
69#[derive(
70    Debug,
71    Clone,
72    PartialEq,
73    Eq,
74    PartialOrd,
75    Ord,
76    Hash,
77    conjure_object::serde::Deserialize,
78    conjure_object::serde::Serialize,
79    conjure_object::log_safety::derive::LogSafe,
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}