Skip to main content

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

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4/// Identifies where a compute query originated from. Used for observability (perf metrics, ClickHouse log_comment)
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 QuerySource {
18    #[serde(rename = "WORKBOOK")]
19    Workbook,
20    #[serde(rename = "CHECKLIST")]
21    Checklist,
22    #[serde(rename = "STREAMING_CHECKLIST")]
23    StreamingChecklist,
24    #[serde(rename = "EXPORT")]
25    Export,
26    #[serde(rename = "PERSISTENT_COMPUTE")]
27    PersistentCompute,
28    /// An unknown variant.
29    #[serde(untagged)]
30    Unknown(Unknown),
31}
32impl QuerySource {
33    /// Returns the string representation of the enum.
34    #[inline]
35    pub fn as_str(&self) -> &str {
36        match self {
37            QuerySource::Workbook => "WORKBOOK",
38            QuerySource::Checklist => "CHECKLIST",
39            QuerySource::StreamingChecklist => "STREAMING_CHECKLIST",
40            QuerySource::Export => "EXPORT",
41            QuerySource::PersistentCompute => "PERSISTENT_COMPUTE",
42            QuerySource::Unknown(v) => &*v,
43        }
44    }
45}
46impl fmt::Display for QuerySource {
47    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
48        fmt::Display::fmt(self.as_str(), fmt)
49    }
50}
51impl conjure_object::Plain for QuerySource {
52    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
53        conjure_object::Plain::fmt(self.as_str(), fmt)
54    }
55}
56impl str::FromStr for QuerySource {
57    type Err = conjure_object::plain::ParseEnumError;
58    #[inline]
59    fn from_str(v: &str) -> Result<QuerySource, conjure_object::plain::ParseEnumError> {
60        match v {
61            "WORKBOOK" => Ok(QuerySource::Workbook),
62            "CHECKLIST" => Ok(QuerySource::Checklist),
63            "STREAMING_CHECKLIST" => Ok(QuerySource::StreamingChecklist),
64            "EXPORT" => Ok(QuerySource::Export),
65            "PERSISTENT_COMPUTE" => Ok(QuerySource::PersistentCompute),
66            v => v.parse().map(|v| QuerySource::Unknown(Unknown(v))),
67        }
68    }
69}
70impl conjure_object::FromPlain for QuerySource {
71    type Err = conjure_object::plain::ParseEnumError;
72    #[inline]
73    fn from_plain(
74        v: &str,
75    ) -> Result<QuerySource, conjure_object::plain::ParseEnumError> {
76        v.parse()
77    }
78}
79///An unknown variant of the QuerySource enum.
80#[derive(
81    Debug,
82    Clone,
83    PartialEq,
84    Eq,
85    PartialOrd,
86    Ord,
87    Hash,
88    conjure_object::serde::Deserialize,
89    conjure_object::serde::Serialize,
90)]
91#[serde(crate = "conjure_object::serde", transparent)]
92pub struct Unknown(conjure_object::private::Variant);
93impl std::ops::Deref for Unknown {
94    type Target = str;
95    #[inline]
96    fn deref(&self) -> &str {
97        &self.0
98    }
99}
100impl fmt::Display for Unknown {
101    #[inline]
102    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
103        fmt::Display::fmt(&self.0, fmt)
104    }
105}