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