nominal_api/conjure/objects/scout/video/api/
search_videos_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 SearchVideosQuery {
7 SearchText(String),
8 Label(super::super::super::super::api::Label),
9 Property(super::super::super::super::api::Property),
10 And(std::collections::BTreeSet<super::SearchVideosQuery>),
11 Or(std::collections::BTreeSet<super::SearchVideosQuery>),
12 IngestStatus(super::super::super::super::api::IngestStatus),
13 Workspace(super::super::super::super::api::rids::WorkspaceRid),
14 Unknown(Unknown),
16}
17impl ser::Serialize for SearchVideosQuery {
18 fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
19 where
20 S: ser::Serializer,
21 {
22 let mut map = s.serialize_map(Some(2))?;
23 match self {
24 SearchVideosQuery::SearchText(value) => {
25 map.serialize_entry(&"type", &"searchText")?;
26 map.serialize_entry(&"searchText", value)?;
27 }
28 SearchVideosQuery::Label(value) => {
29 map.serialize_entry(&"type", &"label")?;
30 map.serialize_entry(&"label", value)?;
31 }
32 SearchVideosQuery::Property(value) => {
33 map.serialize_entry(&"type", &"property")?;
34 map.serialize_entry(&"property", value)?;
35 }
36 SearchVideosQuery::And(value) => {
37 map.serialize_entry(&"type", &"and")?;
38 map.serialize_entry(&"and", value)?;
39 }
40 SearchVideosQuery::Or(value) => {
41 map.serialize_entry(&"type", &"or")?;
42 map.serialize_entry(&"or", value)?;
43 }
44 SearchVideosQuery::IngestStatus(value) => {
45 map.serialize_entry(&"type", &"ingestStatus")?;
46 map.serialize_entry(&"ingestStatus", value)?;
47 }
48 SearchVideosQuery::Workspace(value) => {
49 map.serialize_entry(&"type", &"workspace")?;
50 map.serialize_entry(&"workspace", value)?;
51 }
52 SearchVideosQuery::Unknown(value) => {
53 map.serialize_entry(&"type", &value.type_)?;
54 map.serialize_entry(&value.type_, &value.value)?;
55 }
56 }
57 map.end()
58 }
59}
60impl<'de> de::Deserialize<'de> for SearchVideosQuery {
61 fn deserialize<D>(d: D) -> Result<SearchVideosQuery, D::Error>
62 where
63 D: de::Deserializer<'de>,
64 {
65 d.deserialize_map(Visitor_)
66 }
67}
68struct Visitor_;
69impl<'de> de::Visitor<'de> for Visitor_ {
70 type Value = SearchVideosQuery;
71 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
72 fmt.write_str("union SearchVideosQuery")
73 }
74 fn visit_map<A>(self, mut map: A) -> Result<SearchVideosQuery, A::Error>
75 where
76 A: de::MapAccess<'de>,
77 {
78 let v = match map.next_key::<UnionField_<Variant_>>()? {
79 Some(UnionField_::Type) => {
80 let variant = map.next_value()?;
81 let key = map.next_key()?;
82 match (variant, key) {
83 (Variant_::SearchText, Some(Variant_::SearchText)) => {
84 let value = map.next_value()?;
85 SearchVideosQuery::SearchText(value)
86 }
87 (Variant_::Label, Some(Variant_::Label)) => {
88 let value = map.next_value()?;
89 SearchVideosQuery::Label(value)
90 }
91 (Variant_::Property, Some(Variant_::Property)) => {
92 let value = map.next_value()?;
93 SearchVideosQuery::Property(value)
94 }
95 (Variant_::And, Some(Variant_::And)) => {
96 let value = map.next_value()?;
97 SearchVideosQuery::And(value)
98 }
99 (Variant_::Or, Some(Variant_::Or)) => {
100 let value = map.next_value()?;
101 SearchVideosQuery::Or(value)
102 }
103 (Variant_::IngestStatus, Some(Variant_::IngestStatus)) => {
104 let value = map.next_value()?;
105 SearchVideosQuery::IngestStatus(value)
106 }
107 (Variant_::Workspace, Some(Variant_::Workspace)) => {
108 let value = map.next_value()?;
109 SearchVideosQuery::Workspace(value)
110 }
111 (Variant_::Unknown(type_), Some(Variant_::Unknown(b))) => {
112 if type_ == b {
113 let value = map.next_value()?;
114 SearchVideosQuery::Unknown(Unknown { type_, value })
115 } else {
116 return Err(
117 de::Error::invalid_value(de::Unexpected::Str(&type_), &&*b),
118 )
119 }
120 }
121 (variant, Some(key)) => {
122 return Err(
123 de::Error::invalid_value(
124 de::Unexpected::Str(key.as_str()),
125 &variant.as_str(),
126 ),
127 );
128 }
129 (variant, None) => {
130 return Err(de::Error::missing_field(variant.as_str()));
131 }
132 }
133 }
134 Some(UnionField_::Value(variant)) => {
135 let value = match &variant {
136 Variant_::SearchText => {
137 let value = map.next_value()?;
138 SearchVideosQuery::SearchText(value)
139 }
140 Variant_::Label => {
141 let value = map.next_value()?;
142 SearchVideosQuery::Label(value)
143 }
144 Variant_::Property => {
145 let value = map.next_value()?;
146 SearchVideosQuery::Property(value)
147 }
148 Variant_::And => {
149 let value = map.next_value()?;
150 SearchVideosQuery::And(value)
151 }
152 Variant_::Or => {
153 let value = map.next_value()?;
154 SearchVideosQuery::Or(value)
155 }
156 Variant_::IngestStatus => {
157 let value = map.next_value()?;
158 SearchVideosQuery::IngestStatus(value)
159 }
160 Variant_::Workspace => {
161 let value = map.next_value()?;
162 SearchVideosQuery::Workspace(value)
163 }
164 Variant_::Unknown(type_) => {
165 let value = map.next_value()?;
166 SearchVideosQuery::Unknown(Unknown {
167 type_: type_.clone(),
168 value,
169 })
170 }
171 };
172 if map.next_key::<UnionTypeField_>()?.is_none() {
173 return Err(de::Error::missing_field("type"));
174 }
175 let type_variant = map.next_value::<Variant_>()?;
176 if variant != type_variant {
177 return Err(
178 de::Error::invalid_value(
179 de::Unexpected::Str(type_variant.as_str()),
180 &variant.as_str(),
181 ),
182 );
183 }
184 value
185 }
186 None => return Err(de::Error::missing_field("type")),
187 };
188 if map.next_key::<UnionField_<Variant_>>()?.is_some() {
189 return Err(de::Error::invalid_length(3, &"type and value fields"));
190 }
191 Ok(v)
192 }
193}
194#[derive(PartialEq)]
195enum Variant_ {
196 SearchText,
197 Label,
198 Property,
199 And,
200 Or,
201 IngestStatus,
202 Workspace,
203 Unknown(Box<str>),
204}
205impl Variant_ {
206 fn as_str(&self) -> &'static str {
207 match *self {
208 Variant_::SearchText => "searchText",
209 Variant_::Label => "label",
210 Variant_::Property => "property",
211 Variant_::And => "and",
212 Variant_::Or => "or",
213 Variant_::IngestStatus => "ingestStatus",
214 Variant_::Workspace => "workspace",
215 Variant_::Unknown(_) => "unknown variant",
216 }
217 }
218}
219impl<'de> de::Deserialize<'de> for Variant_ {
220 fn deserialize<D>(d: D) -> Result<Variant_, D::Error>
221 where
222 D: de::Deserializer<'de>,
223 {
224 d.deserialize_str(VariantVisitor_)
225 }
226}
227struct VariantVisitor_;
228impl<'de> de::Visitor<'de> for VariantVisitor_ {
229 type Value = Variant_;
230 fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
231 fmt.write_str("string")
232 }
233 fn visit_str<E>(self, value: &str) -> Result<Variant_, E>
234 where
235 E: de::Error,
236 {
237 let v = match value {
238 "searchText" => Variant_::SearchText,
239 "label" => Variant_::Label,
240 "property" => Variant_::Property,
241 "and" => Variant_::And,
242 "or" => Variant_::Or,
243 "ingestStatus" => Variant_::IngestStatus,
244 "workspace" => Variant_::Workspace,
245 value => Variant_::Unknown(value.to_string().into_boxed_str()),
246 };
247 Ok(v)
248 }
249}
250#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
252pub struct Unknown {
253 type_: Box<str>,
254 value: conjure_object::Any,
255}
256impl Unknown {
257 #[inline]
259 pub fn type_(&self) -> &str {
260 &self.type_
261 }
262}