risingwave_pb/
compute.serde.rs

1use crate::compute::*;
2impl serde::Serialize for ResizeCacheRequest {
3    #[allow(deprecated)]
4    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5    where
6        S: serde::Serializer,
7    {
8        use serde::ser::SerializeStruct;
9        let mut len = 0;
10        if self.meta_cache_capacity != 0 {
11            len += 1;
12        }
13        if self.data_cache_capacity != 0 {
14            len += 1;
15        }
16        let mut struct_ser = serializer.serialize_struct("compute.ResizeCacheRequest", len)?;
17        if self.meta_cache_capacity != 0 {
18            #[allow(clippy::needless_borrow)]
19            #[allow(clippy::needless_borrows_for_generic_args)]
20            struct_ser.serialize_field("metaCacheCapacity", ToString::to_string(&self.meta_cache_capacity).as_str())?;
21        }
22        if self.data_cache_capacity != 0 {
23            #[allow(clippy::needless_borrow)]
24            #[allow(clippy::needless_borrows_for_generic_args)]
25            struct_ser.serialize_field("dataCacheCapacity", ToString::to_string(&self.data_cache_capacity).as_str())?;
26        }
27        struct_ser.end()
28    }
29}
30impl<'de> serde::Deserialize<'de> for ResizeCacheRequest {
31    #[allow(deprecated)]
32    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
33    where
34        D: serde::Deserializer<'de>,
35    {
36        const FIELDS: &[&str] = &[
37            "meta_cache_capacity",
38            "metaCacheCapacity",
39            "data_cache_capacity",
40            "dataCacheCapacity",
41        ];
42
43        #[allow(clippy::enum_variant_names)]
44        enum GeneratedField {
45            MetaCacheCapacity,
46            DataCacheCapacity,
47        }
48        impl<'de> serde::Deserialize<'de> for GeneratedField {
49            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
50            where
51                D: serde::Deserializer<'de>,
52            {
53                struct GeneratedVisitor;
54
55                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
56                    type Value = GeneratedField;
57
58                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59                        write!(formatter, "expected one of: {:?}", &FIELDS)
60                    }
61
62                    #[allow(unused_variables)]
63                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
64                    where
65                        E: serde::de::Error,
66                    {
67                        match value {
68                            "metaCacheCapacity" | "meta_cache_capacity" => Ok(GeneratedField::MetaCacheCapacity),
69                            "dataCacheCapacity" | "data_cache_capacity" => Ok(GeneratedField::DataCacheCapacity),
70                            _ => Err(serde::de::Error::unknown_field(value, FIELDS)),
71                        }
72                    }
73                }
74                deserializer.deserialize_identifier(GeneratedVisitor)
75            }
76        }
77        struct GeneratedVisitor;
78        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
79            type Value = ResizeCacheRequest;
80
81            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82                formatter.write_str("struct compute.ResizeCacheRequest")
83            }
84
85            fn visit_map<V>(self, mut map_: V) -> std::result::Result<ResizeCacheRequest, V::Error>
86                where
87                    V: serde::de::MapAccess<'de>,
88            {
89                let mut meta_cache_capacity__ = None;
90                let mut data_cache_capacity__ = None;
91                while let Some(k) = map_.next_key()? {
92                    match k {
93                        GeneratedField::MetaCacheCapacity => {
94                            if meta_cache_capacity__.is_some() {
95                                return Err(serde::de::Error::duplicate_field("metaCacheCapacity"));
96                            }
97                            meta_cache_capacity__ = 
98                                Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
99                            ;
100                        }
101                        GeneratedField::DataCacheCapacity => {
102                            if data_cache_capacity__.is_some() {
103                                return Err(serde::de::Error::duplicate_field("dataCacheCapacity"));
104                            }
105                            data_cache_capacity__ = 
106                                Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
107                            ;
108                        }
109                    }
110                }
111                Ok(ResizeCacheRequest {
112                    meta_cache_capacity: meta_cache_capacity__.unwrap_or_default(),
113                    data_cache_capacity: data_cache_capacity__.unwrap_or_default(),
114                })
115            }
116        }
117        deserializer.deserialize_struct("compute.ResizeCacheRequest", FIELDS, GeneratedVisitor)
118    }
119}
120impl serde::Serialize for ResizeCacheResponse {
121    #[allow(deprecated)]
122    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
123    where
124        S: serde::Serializer,
125    {
126        use serde::ser::SerializeStruct;
127        let len = 0;
128        let struct_ser = serializer.serialize_struct("compute.ResizeCacheResponse", len)?;
129        struct_ser.end()
130    }
131}
132impl<'de> serde::Deserialize<'de> for ResizeCacheResponse {
133    #[allow(deprecated)]
134    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
135    where
136        D: serde::Deserializer<'de>,
137    {
138        const FIELDS: &[&str] = &[
139        ];
140
141        #[allow(clippy::enum_variant_names)]
142        enum GeneratedField {
143        }
144        impl<'de> serde::Deserialize<'de> for GeneratedField {
145            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
146            where
147                D: serde::Deserializer<'de>,
148            {
149                struct GeneratedVisitor;
150
151                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
152                    type Value = GeneratedField;
153
154                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
155                        write!(formatter, "expected one of: {:?}", &FIELDS)
156                    }
157
158                    #[allow(unused_variables)]
159                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
160                    where
161                        E: serde::de::Error,
162                    {
163                            Err(serde::de::Error::unknown_field(value, FIELDS))
164                    }
165                }
166                deserializer.deserialize_identifier(GeneratedVisitor)
167            }
168        }
169        struct GeneratedVisitor;
170        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
171            type Value = ResizeCacheResponse;
172
173            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
174                formatter.write_str("struct compute.ResizeCacheResponse")
175            }
176
177            fn visit_map<V>(self, mut map_: V) -> std::result::Result<ResizeCacheResponse, V::Error>
178                where
179                    V: serde::de::MapAccess<'de>,
180            {
181                while map_.next_key::<GeneratedField>()?.is_some() {
182                    let _ = map_.next_value::<serde::de::IgnoredAny>()?;
183                }
184                Ok(ResizeCacheResponse {
185                })
186            }
187        }
188        deserializer.deserialize_struct("compute.ResizeCacheResponse", FIELDS, GeneratedVisitor)
189    }
190}
191impl serde::Serialize for ShowConfigRequest {
192    #[allow(deprecated)]
193    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
194    where
195        S: serde::Serializer,
196    {
197        use serde::ser::SerializeStruct;
198        let len = 0;
199        let struct_ser = serializer.serialize_struct("compute.ShowConfigRequest", len)?;
200        struct_ser.end()
201    }
202}
203impl<'de> serde::Deserialize<'de> for ShowConfigRequest {
204    #[allow(deprecated)]
205    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
206    where
207        D: serde::Deserializer<'de>,
208    {
209        const FIELDS: &[&str] = &[
210        ];
211
212        #[allow(clippy::enum_variant_names)]
213        enum GeneratedField {
214        }
215        impl<'de> serde::Deserialize<'de> for GeneratedField {
216            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
217            where
218                D: serde::Deserializer<'de>,
219            {
220                struct GeneratedVisitor;
221
222                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
223                    type Value = GeneratedField;
224
225                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
226                        write!(formatter, "expected one of: {:?}", &FIELDS)
227                    }
228
229                    #[allow(unused_variables)]
230                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
231                    where
232                        E: serde::de::Error,
233                    {
234                            Err(serde::de::Error::unknown_field(value, FIELDS))
235                    }
236                }
237                deserializer.deserialize_identifier(GeneratedVisitor)
238            }
239        }
240        struct GeneratedVisitor;
241        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
242            type Value = ShowConfigRequest;
243
244            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
245                formatter.write_str("struct compute.ShowConfigRequest")
246            }
247
248            fn visit_map<V>(self, mut map_: V) -> std::result::Result<ShowConfigRequest, V::Error>
249                where
250                    V: serde::de::MapAccess<'de>,
251            {
252                while map_.next_key::<GeneratedField>()?.is_some() {
253                    let _ = map_.next_value::<serde::de::IgnoredAny>()?;
254                }
255                Ok(ShowConfigRequest {
256                })
257            }
258        }
259        deserializer.deserialize_struct("compute.ShowConfigRequest", FIELDS, GeneratedVisitor)
260    }
261}
262impl serde::Serialize for ShowConfigResponse {
263    #[allow(deprecated)]
264    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
265    where
266        S: serde::Serializer,
267    {
268        use serde::ser::SerializeStruct;
269        let mut len = 0;
270        if !self.batch_config.is_empty() {
271            len += 1;
272        }
273        if !self.stream_config.is_empty() {
274            len += 1;
275        }
276        let mut struct_ser = serializer.serialize_struct("compute.ShowConfigResponse", len)?;
277        if !self.batch_config.is_empty() {
278            struct_ser.serialize_field("batchConfig", &self.batch_config)?;
279        }
280        if !self.stream_config.is_empty() {
281            struct_ser.serialize_field("streamConfig", &self.stream_config)?;
282        }
283        struct_ser.end()
284    }
285}
286impl<'de> serde::Deserialize<'de> for ShowConfigResponse {
287    #[allow(deprecated)]
288    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
289    where
290        D: serde::Deserializer<'de>,
291    {
292        const FIELDS: &[&str] = &[
293            "batch_config",
294            "batchConfig",
295            "stream_config",
296            "streamConfig",
297        ];
298
299        #[allow(clippy::enum_variant_names)]
300        enum GeneratedField {
301            BatchConfig,
302            StreamConfig,
303        }
304        impl<'de> serde::Deserialize<'de> for GeneratedField {
305            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
306            where
307                D: serde::Deserializer<'de>,
308            {
309                struct GeneratedVisitor;
310
311                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
312                    type Value = GeneratedField;
313
314                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
315                        write!(formatter, "expected one of: {:?}", &FIELDS)
316                    }
317
318                    #[allow(unused_variables)]
319                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
320                    where
321                        E: serde::de::Error,
322                    {
323                        match value {
324                            "batchConfig" | "batch_config" => Ok(GeneratedField::BatchConfig),
325                            "streamConfig" | "stream_config" => Ok(GeneratedField::StreamConfig),
326                            _ => Err(serde::de::Error::unknown_field(value, FIELDS)),
327                        }
328                    }
329                }
330                deserializer.deserialize_identifier(GeneratedVisitor)
331            }
332        }
333        struct GeneratedVisitor;
334        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
335            type Value = ShowConfigResponse;
336
337            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
338                formatter.write_str("struct compute.ShowConfigResponse")
339            }
340
341            fn visit_map<V>(self, mut map_: V) -> std::result::Result<ShowConfigResponse, V::Error>
342                where
343                    V: serde::de::MapAccess<'de>,
344            {
345                let mut batch_config__ = None;
346                let mut stream_config__ = None;
347                while let Some(k) = map_.next_key()? {
348                    match k {
349                        GeneratedField::BatchConfig => {
350                            if batch_config__.is_some() {
351                                return Err(serde::de::Error::duplicate_field("batchConfig"));
352                            }
353                            batch_config__ = Some(map_.next_value()?);
354                        }
355                        GeneratedField::StreamConfig => {
356                            if stream_config__.is_some() {
357                                return Err(serde::de::Error::duplicate_field("streamConfig"));
358                            }
359                            stream_config__ = Some(map_.next_value()?);
360                        }
361                    }
362                }
363                Ok(ShowConfigResponse {
364                    batch_config: batch_config__.unwrap_or_default(),
365                    stream_config: stream_config__.unwrap_or_default(),
366                })
367            }
368        }
369        deserializer.deserialize_struct("compute.ShowConfigResponse", FIELDS, GeneratedVisitor)
370    }
371}