nominal_api/conjure/objects/scout/catalog/
search_datasets_query.rs1use conjure_object::serde::{ser, de};
2use conjure_object::serde::ser::SerializeMap as SerializeMap_;
3use conjure_object::private::{UnionField_, UnionTypeField_};
4use std::fmt;
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub enum SearchDatasetsQuery {
7 SearchText(String),
8 ExactMatch(String),
10 Label(super::super::super::api::Label),
11 Properties(super::super::super::api::Property),
12 IngestStatus(super::IngestStatus),
13 IngestedBeforeInclusive(conjure_object::DateTime<conjure_object::Utc>),
14 IngestedAfterInclusive(conjure_object::DateTime<conjure_object::Utc>),
15 ArchiveStatus(bool),
16 And(std::collections::BTreeSet<super::SearchDatasetsQuery>),
17 Or(std::collections::BTreeSet<super::SearchDatasetsQuery>),
18 Workspace(super::super::super::api::rids::WorkspaceRid),
19 Unknown(Unknown),
21}
22impl ser::Serialize for SearchDatasetsQuery {
23 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
24 where
25 S: ser::Serializer,
26 {
27 let mut map = s.serialize_map(Some(2))?;
28 match self {
29 SearchDatasetsQuery::SearchText(value) => {
30 map.serialize_entry(&"type", &"searchText")?;
31 map.serialize_entry(&"searchText", value)?;
32 }
33 SearchDatasetsQuery::ExactMatch(value) => {
34 map.serialize_entry(&"type", &"exactMatch")?;
35 map.serialize_entry(&"exactMatch", value)?;
36 }
37 SearchDatasetsQuery::Label(value) => {
38 map.serialize_entry(&"type", &"label")?;
39 map.serialize_entry(&"label", value)?;
40 }
41 SearchDatasetsQuery::Properties(value) => {
42 map.serialize_entry(&"type", &"properties")?;
43 map.serialize_entry(&"properties", value)?;
44 }
45 SearchDatasetsQuery::IngestStatus(value) => {
46 map.serialize_entry(&"type", &"ingestStatus")?;
47 map.serialize_entry(&"ingestStatus", value)?;
48 }
49 SearchDatasetsQuery::IngestedBeforeInclusive(value) => {
50 map.serialize_entry(&"type", &"ingestedBeforeInclusive")?;
51 map.serialize_entry(&"ingestedBeforeInclusive", value)?;
52 }
53 SearchDatasetsQuery::IngestedAfterInclusive(value) => {
54 map.serialize_entry(&"type", &"ingestedAfterInclusive")?;
55 map.serialize_entry(&"ingestedAfterInclusive", value)?;
56 }
57 SearchDatasetsQuery::ArchiveStatus(value) => {
58 map.serialize_entry(&"type", &"archiveStatus")?;
59 map.serialize_entry(&"archiveStatus", value)?;
60 }
61 SearchDatasetsQuery::And(value) => {
62 map.serialize_entry(&"type", &"and")?;
63 map.serialize_entry(&"and", value)?;
64 }
65 SearchDatasetsQuery::Or(value) => {
66 map.serialize_entry(&"type", &"or")?;
67 map.serialize_entry(&"or", value)?;
68 }
69 SearchDatasetsQuery::Workspace(value) => {
70 map.serialize_entry(&"type", &"workspace")?;
71 map.serialize_entry(&"workspace", value)?;
72 }
73 SearchDatasetsQuery::Unknown(value) => {
74 map.serialize_entry(&"type", &value.type_)?;
75 map.serialize_entry(&value.type_, &value.value)?;
76 }
77 }
78 map.end()
79 }
80}
81impl<'de> de::Deserialize<'de> for SearchDatasetsQuery {
82 fn deserialize<D>(d: D) -> Result<SearchDatasetsQuery, D::Error>
83 where
84 D: de::Deserializer<'de>,
85 {
86 d.deserialize_map(Visitor_)
87 }
88}
89struct Visitor_;
90impl<'de> de::Visitor<'de> for Visitor_ {
91 type Value = SearchDatasetsQuery;
92 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
93 fmt.write_str("union SearchDatasetsQuery")
94 }
95 fn visit_map<A>(self, mut map: A) -> Result<SearchDatasetsQuery, A::Error>
96 where
97 A: de::MapAccess<'de>,
98 {
99 let v = match map.next_key::<UnionField_<Variant_>>()? {
100 Some(UnionField_::Type) => {
101 let variant = map.next_value()?;
102 let key = map.next_key()?;
103 match (variant, key) {
104 (Variant_::SearchText, Some(Variant_::SearchText)) => {
105 let value = map.next_value()?;
106 SearchDatasetsQuery::SearchText(value)
107 }
108 (Variant_::ExactMatch, Some(Variant_::ExactMatch)) => {
109 let value = map.next_value()?;
110 SearchDatasetsQuery::ExactMatch(value)
111 }
112 (Variant_::Label, Some(Variant_::Label)) => {
113 let value = map.next_value()?;
114 SearchDatasetsQuery::Label(value)
115 }
116 (Variant_::Properties, Some(Variant_::Properties)) => {
117 let value = map.next_value()?;
118 SearchDatasetsQuery::Properties(value)
119 }
120 (Variant_::IngestStatus, Some(Variant_::IngestStatus)) => {
121 let value = map.next_value()?;
122 SearchDatasetsQuery::IngestStatus(value)
123 }
124 (
125 Variant_::IngestedBeforeInclusive,
126 Some(Variant_::IngestedBeforeInclusive),
127 ) => {
128 let value = map.next_value()?;
129 SearchDatasetsQuery::IngestedBeforeInclusive(value)
130 }
131 (
132 Variant_::IngestedAfterInclusive,
133 Some(Variant_::IngestedAfterInclusive),
134 ) => {
135 let value = map.next_value()?;
136 SearchDatasetsQuery::IngestedAfterInclusive(value)
137 }
138 (Variant_::ArchiveStatus, Some(Variant_::ArchiveStatus)) => {
139 let value = map.next_value()?;
140 SearchDatasetsQuery::ArchiveStatus(value)
141 }
142 (Variant_::And, Some(Variant_::And)) => {
143 let value = map.next_value()?;
144 SearchDatasetsQuery::And(value)
145 }
146 (Variant_::Or, Some(Variant_::Or)) => {
147 let value = map.next_value()?;
148 SearchDatasetsQuery::Or(value)
149 }
150 (Variant_::Workspace, Some(Variant_::Workspace)) => {
151 let value = map.next_value()?;
152 SearchDatasetsQuery::Workspace(value)
153 }
154 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
155 if type_ == b {
156 let value = map.next_value()?;
157 SearchDatasetsQuery::Unknown(Unknown { type_, value })
158 } else {
159 return Err(
160 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
161 )
162 }
163 }
164 (variant, Some(key)) => {
165 return Err(
166 de::Error::invalid_value(
167 de::Unexpected::Str(key.as_str()),
168 &variant.as_str(),
169 ),
170 );
171 }
172 (variant, None) => {
173 return Err(de::Error::missing_field(variant.as_str()));
174 }
175 }
176 }
177 Some(UnionField_::Value(variant)) => {
178 let value = match &variant {
179 Variant_::SearchText => {
180 let value = map.next_value()?;
181 SearchDatasetsQuery::SearchText(value)
182 }
183 Variant_::ExactMatch => {
184 let value = map.next_value()?;
185 SearchDatasetsQuery::ExactMatch(value)
186 }
187 Variant_::Label => {
188 let value = map.next_value()?;
189 SearchDatasetsQuery::Label(value)
190 }
191 Variant_::Properties => {
192 let value = map.next_value()?;
193 SearchDatasetsQuery::Properties(value)
194 }
195 Variant_::IngestStatus => {
196 let value = map.next_value()?;
197 SearchDatasetsQuery::IngestStatus(value)
198 }
199 Variant_::IngestedBeforeInclusive => {
200 let value = map.next_value()?;
201 SearchDatasetsQuery::IngestedBeforeInclusive(value)
202 }
203 Variant_::IngestedAfterInclusive => {
204 let value = map.next_value()?;
205 SearchDatasetsQuery::IngestedAfterInclusive(value)
206 }
207 Variant_::ArchiveStatus => {
208 let value = map.next_value()?;
209 SearchDatasetsQuery::ArchiveStatus(value)
210 }
211 Variant_::And => {
212 let value = map.next_value()?;
213 SearchDatasetsQuery::And(value)
214 }
215 Variant_::Or => {
216 let value = map.next_value()?;
217 SearchDatasetsQuery::Or(value)
218 }
219 Variant_::Workspace => {
220 let value = map.next_value()?;
221 SearchDatasetsQuery::Workspace(value)
222 }
223 Variant_::Unknown(type_) => {
224 let value = map.next_value()?;
225 SearchDatasetsQuery::Unknown(Unknown {
226 type_: type_.clone(),
227 value,
228 })
229 }
230 };
231 if map.next_key::<UnionTypeField_>()?.is_none() {
232 return Err(de::Error::missing_field("type"));
233 }
234 let type_variant = map.next_value::<Variant_>()?;
235 if variant != type_variant {
236 return Err(
237 de::Error::invalid_value(
238 de::Unexpected::Str(type_variant.as_str()),
239 &variant.as_str(),
240 ),
241 );
242 }
243 value
244 }
245 None => return Err(de::Error::missing_field("type")),
246 };
247 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
248 return Err(de::Error::invalid_length(3, &"type and value fields"));
249 }
250 Ok(v)
251 }
252}
253#[derive(PartialEq)]
254enum Variant_ {
255 SearchText,
256 ExactMatch,
257 Label,
258 Properties,
259 IngestStatus,
260 IngestedBeforeInclusive,
261 IngestedAfterInclusive,
262 ArchiveStatus,
263 And,
264 Or,
265 Workspace,
266 Unknown(Box<str>),
267}
268impl Variant_ {
269 fn as_str(&self) -> &'static str {
270 match *self {
271 Variant_::SearchText => "searchText",
272 Variant_::ExactMatch => "exactMatch",
273 Variant_::Label => "label",
274 Variant_::Properties => "properties",
275 Variant_::IngestStatus => "ingestStatus",
276 Variant_::IngestedBeforeInclusive => "ingestedBeforeInclusive",
277 Variant_::IngestedAfterInclusive => "ingestedAfterInclusive",
278 Variant_::ArchiveStatus => "archiveStatus",
279 Variant_::And => "and",
280 Variant_::Or => "or",
281 Variant_::Workspace => "workspace",
282 Variant_::Unknown(_) => "unknown variant",
283 }
284 }
285}
286impl<'de> de::Deserialize<'de> for Variant_ {
287 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
288 where
289 D: de::Deserializer<'de>,
290 {
291 d.deserialize_str(VariantVisitor_)
292 }
293}
294struct VariantVisitor_;
295impl<'de> de::Visitor<'de> for VariantVisitor_ {
296 type Value = Variant_;
297 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
298 fmt.write_str("string")
299 }
300 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
301 where
302 E: de::Error,
303 {
304 let v = match value {
305 "searchText" => Variant_::SearchText,
306 "exactMatch" => Variant_::ExactMatch,
307 "label" => Variant_::Label,
308 "properties" => Variant_::Properties,
309 "ingestStatus" => Variant_::IngestStatus,
310 "ingestedBeforeInclusive" => Variant_::IngestedBeforeInclusive,
311 "ingestedAfterInclusive" => Variant_::IngestedAfterInclusive,
312 "archiveStatus" => Variant_::ArchiveStatus,
313 "and" => Variant_::And,
314 "or" => Variant_::Or,
315 "workspace" => Variant_::Workspace,
316 value => Variant_::Unknown(value.to_string().into_boxed_str()),
317 };
318 Ok(v)
319 }
320}
321#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
323pub struct Unknown {
324 type_: Box<str>,
325 value: conjure_object::Any,
326}
327impl Unknown {
328 #[inline]
330 pub fn type_(&self) -> &str {
331 &self.type_
332 }
333}