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