Skip to main content

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