risingwave_pb/
compactor.serde.rs

1use crate::compactor::*;
2impl serde::Serialize for DispatchCompactionTaskRequest {
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.tables.is_empty() {
11            len += 1;
12        }
13        if !self.output_object_ids.is_empty() {
14            len += 1;
15        }
16        if self.task.is_some() {
17            len += 1;
18        }
19        let mut struct_ser = serializer.serialize_struct("compactor.DispatchCompactionTaskRequest", len)?;
20        if !self.tables.is_empty() {
21            struct_ser.serialize_field("tables", &self.tables)?;
22        }
23        if !self.output_object_ids.is_empty() {
24            struct_ser.serialize_field("outputObjectIds", &self.output_object_ids.iter().map(ToString::to_string).collect::<Vec<_>>())?;
25        }
26        if let Some(v) = self.task.as_ref() {
27            match v {
28                dispatch_compaction_task_request::Task::CompactTask(v) => {
29                    struct_ser.serialize_field("compactTask", v)?;
30                }
31                dispatch_compaction_task_request::Task::VacuumTask(v) => {
32                    struct_ser.serialize_field("vacuumTask", v)?;
33                }
34                dispatch_compaction_task_request::Task::FullScanTask(v) => {
35                    struct_ser.serialize_field("fullScanTask", v)?;
36                }
37                dispatch_compaction_task_request::Task::ValidationTask(v) => {
38                    struct_ser.serialize_field("validationTask", v)?;
39                }
40                dispatch_compaction_task_request::Task::CancelCompactTask(v) => {
41                    struct_ser.serialize_field("cancelCompactTask", v)?;
42                }
43            }
44        }
45        struct_ser.end()
46    }
47}
48impl<'de> serde::Deserialize<'de> for DispatchCompactionTaskRequest {
49    #[allow(deprecated)]
50    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
51    where
52        D: serde::Deserializer<'de>,
53    {
54        const FIELDS: &[&str] = &[
55            "tables",
56            "output_object_ids",
57            "outputObjectIds",
58            "compact_task",
59            "compactTask",
60            "vacuum_task",
61            "vacuumTask",
62            "full_scan_task",
63            "fullScanTask",
64            "validation_task",
65            "validationTask",
66            "cancel_compact_task",
67            "cancelCompactTask",
68        ];
69
70        #[allow(clippy::enum_variant_names)]
71        enum GeneratedField {
72            Tables,
73            OutputObjectIds,
74            CompactTask,
75            VacuumTask,
76            FullScanTask,
77            ValidationTask,
78            CancelCompactTask,
79        }
80        impl<'de> serde::Deserialize<'de> for GeneratedField {
81            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
82            where
83                D: serde::Deserializer<'de>,
84            {
85                struct GeneratedVisitor;
86
87                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
88                    type Value = GeneratedField;
89
90                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
91                        write!(formatter, "expected one of: {:?}", &FIELDS)
92                    }
93
94                    #[allow(unused_variables)]
95                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
96                    where
97                        E: serde::de::Error,
98                    {
99                        match value {
100                            "tables" => Ok(GeneratedField::Tables),
101                            "outputObjectIds" | "output_object_ids" => Ok(GeneratedField::OutputObjectIds),
102                            "compactTask" | "compact_task" => Ok(GeneratedField::CompactTask),
103                            "vacuumTask" | "vacuum_task" => Ok(GeneratedField::VacuumTask),
104                            "fullScanTask" | "full_scan_task" => Ok(GeneratedField::FullScanTask),
105                            "validationTask" | "validation_task" => Ok(GeneratedField::ValidationTask),
106                            "cancelCompactTask" | "cancel_compact_task" => Ok(GeneratedField::CancelCompactTask),
107                            _ => Err(serde::de::Error::unknown_field(value, FIELDS)),
108                        }
109                    }
110                }
111                deserializer.deserialize_identifier(GeneratedVisitor)
112            }
113        }
114        struct GeneratedVisitor;
115        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
116            type Value = DispatchCompactionTaskRequest;
117
118            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
119                formatter.write_str("struct compactor.DispatchCompactionTaskRequest")
120            }
121
122            fn visit_map<V>(self, mut map_: V) -> std::result::Result<DispatchCompactionTaskRequest, V::Error>
123                where
124                    V: serde::de::MapAccess<'de>,
125            {
126                let mut tables__ = None;
127                let mut output_object_ids__ = None;
128                let mut task__ = None;
129                while let Some(k) = map_.next_key()? {
130                    match k {
131                        GeneratedField::Tables => {
132                            if tables__.is_some() {
133                                return Err(serde::de::Error::duplicate_field("tables"));
134                            }
135                            tables__ = Some(map_.next_value()?);
136                        }
137                        GeneratedField::OutputObjectIds => {
138                            if output_object_ids__.is_some() {
139                                return Err(serde::de::Error::duplicate_field("outputObjectIds"));
140                            }
141                            output_object_ids__ = 
142                                Some(map_.next_value::<Vec<::pbjson::private::NumberDeserialize<_>>>()?
143                                    .into_iter().map(|x| x.0).collect())
144                            ;
145                        }
146                        GeneratedField::CompactTask => {
147                            if task__.is_some() {
148                                return Err(serde::de::Error::duplicate_field("compactTask"));
149                            }
150                            task__ = map_.next_value::<::std::option::Option<_>>()?.map(dispatch_compaction_task_request::Task::CompactTask)
151;
152                        }
153                        GeneratedField::VacuumTask => {
154                            if task__.is_some() {
155                                return Err(serde::de::Error::duplicate_field("vacuumTask"));
156                            }
157                            task__ = map_.next_value::<::std::option::Option<_>>()?.map(dispatch_compaction_task_request::Task::VacuumTask)
158;
159                        }
160                        GeneratedField::FullScanTask => {
161                            if task__.is_some() {
162                                return Err(serde::de::Error::duplicate_field("fullScanTask"));
163                            }
164                            task__ = map_.next_value::<::std::option::Option<_>>()?.map(dispatch_compaction_task_request::Task::FullScanTask)
165;
166                        }
167                        GeneratedField::ValidationTask => {
168                            if task__.is_some() {
169                                return Err(serde::de::Error::duplicate_field("validationTask"));
170                            }
171                            task__ = map_.next_value::<::std::option::Option<_>>()?.map(dispatch_compaction_task_request::Task::ValidationTask)
172;
173                        }
174                        GeneratedField::CancelCompactTask => {
175                            if task__.is_some() {
176                                return Err(serde::de::Error::duplicate_field("cancelCompactTask"));
177                            }
178                            task__ = map_.next_value::<::std::option::Option<_>>()?.map(dispatch_compaction_task_request::Task::CancelCompactTask)
179;
180                        }
181                    }
182                }
183                Ok(DispatchCompactionTaskRequest {
184                    tables: tables__.unwrap_or_default(),
185                    output_object_ids: output_object_ids__.unwrap_or_default(),
186                    task: task__,
187                })
188            }
189        }
190        deserializer.deserialize_struct("compactor.DispatchCompactionTaskRequest", FIELDS, GeneratedVisitor)
191    }
192}
193impl serde::Serialize for DispatchCompactionTaskResponse {
194    #[allow(deprecated)]
195    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
196    where
197        S: serde::Serializer,
198    {
199        use serde::ser::SerializeStruct;
200        let mut len = 0;
201        if self.status.is_some() {
202            len += 1;
203        }
204        let mut struct_ser = serializer.serialize_struct("compactor.DispatchCompactionTaskResponse", len)?;
205        if let Some(v) = self.status.as_ref() {
206            struct_ser.serialize_field("status", v)?;
207        }
208        struct_ser.end()
209    }
210}
211impl<'de> serde::Deserialize<'de> for DispatchCompactionTaskResponse {
212    #[allow(deprecated)]
213    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
214    where
215        D: serde::Deserializer<'de>,
216    {
217        const FIELDS: &[&str] = &[
218            "status",
219        ];
220
221        #[allow(clippy::enum_variant_names)]
222        enum GeneratedField {
223            Status,
224        }
225        impl<'de> serde::Deserialize<'de> for GeneratedField {
226            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
227            where
228                D: serde::Deserializer<'de>,
229            {
230                struct GeneratedVisitor;
231
232                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
233                    type Value = GeneratedField;
234
235                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
236                        write!(formatter, "expected one of: {:?}", &FIELDS)
237                    }
238
239                    #[allow(unused_variables)]
240                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
241                    where
242                        E: serde::de::Error,
243                    {
244                        match value {
245                            "status" => Ok(GeneratedField::Status),
246                            _ => Err(serde::de::Error::unknown_field(value, FIELDS)),
247                        }
248                    }
249                }
250                deserializer.deserialize_identifier(GeneratedVisitor)
251            }
252        }
253        struct GeneratedVisitor;
254        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
255            type Value = DispatchCompactionTaskResponse;
256
257            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
258                formatter.write_str("struct compactor.DispatchCompactionTaskResponse")
259            }
260
261            fn visit_map<V>(self, mut map_: V) -> std::result::Result<DispatchCompactionTaskResponse, V::Error>
262                where
263                    V: serde::de::MapAccess<'de>,
264            {
265                let mut status__ = None;
266                while let Some(k) = map_.next_key()? {
267                    match k {
268                        GeneratedField::Status => {
269                            if status__.is_some() {
270                                return Err(serde::de::Error::duplicate_field("status"));
271                            }
272                            status__ = map_.next_value()?;
273                        }
274                    }
275                }
276                Ok(DispatchCompactionTaskResponse {
277                    status: status__,
278                })
279            }
280        }
281        deserializer.deserialize_struct("compactor.DispatchCompactionTaskResponse", FIELDS, GeneratedVisitor)
282    }
283}
284impl serde::Serialize for EchoRequest {
285    #[allow(deprecated)]
286    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
287    where
288        S: serde::Serializer,
289    {
290        use serde::ser::SerializeStruct;
291        let len = 0;
292        let struct_ser = serializer.serialize_struct("compactor.EchoRequest", len)?;
293        struct_ser.end()
294    }
295}
296impl<'de> serde::Deserialize<'de> for EchoRequest {
297    #[allow(deprecated)]
298    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
299    where
300        D: serde::Deserializer<'de>,
301    {
302        const FIELDS: &[&str] = &[
303        ];
304
305        #[allow(clippy::enum_variant_names)]
306        enum GeneratedField {
307        }
308        impl<'de> serde::Deserialize<'de> for GeneratedField {
309            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
310            where
311                D: serde::Deserializer<'de>,
312            {
313                struct GeneratedVisitor;
314
315                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
316                    type Value = GeneratedField;
317
318                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
319                        write!(formatter, "expected one of: {:?}", &FIELDS)
320                    }
321
322                    #[allow(unused_variables)]
323                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
324                    where
325                        E: serde::de::Error,
326                    {
327                            Err(serde::de::Error::unknown_field(value, FIELDS))
328                    }
329                }
330                deserializer.deserialize_identifier(GeneratedVisitor)
331            }
332        }
333        struct GeneratedVisitor;
334        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
335            type Value = EchoRequest;
336
337            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
338                formatter.write_str("struct compactor.EchoRequest")
339            }
340
341            fn visit_map<V>(self, mut map_: V) -> std::result::Result<EchoRequest, V::Error>
342                where
343                    V: serde::de::MapAccess<'de>,
344            {
345                while map_.next_key::<GeneratedField>()?.is_some() {
346                    let _ = map_.next_value::<serde::de::IgnoredAny>()?;
347                }
348                Ok(EchoRequest {
349                })
350            }
351        }
352        deserializer.deserialize_struct("compactor.EchoRequest", FIELDS, GeneratedVisitor)
353    }
354}
355impl serde::Serialize for EchoResponse {
356    #[allow(deprecated)]
357    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
358    where
359        S: serde::Serializer,
360    {
361        use serde::ser::SerializeStruct;
362        let len = 0;
363        let struct_ser = serializer.serialize_struct("compactor.EchoResponse", len)?;
364        struct_ser.end()
365    }
366}
367impl<'de> serde::Deserialize<'de> for EchoResponse {
368    #[allow(deprecated)]
369    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
370    where
371        D: serde::Deserializer<'de>,
372    {
373        const FIELDS: &[&str] = &[
374        ];
375
376        #[allow(clippy::enum_variant_names)]
377        enum GeneratedField {
378        }
379        impl<'de> serde::Deserialize<'de> for GeneratedField {
380            fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
381            where
382                D: serde::Deserializer<'de>,
383            {
384                struct GeneratedVisitor;
385
386                impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
387                    type Value = GeneratedField;
388
389                    fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
390                        write!(formatter, "expected one of: {:?}", &FIELDS)
391                    }
392
393                    #[allow(unused_variables)]
394                    fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
395                    where
396                        E: serde::de::Error,
397                    {
398                            Err(serde::de::Error::unknown_field(value, FIELDS))
399                    }
400                }
401                deserializer.deserialize_identifier(GeneratedVisitor)
402            }
403        }
404        struct GeneratedVisitor;
405        impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
406            type Value = EchoResponse;
407
408            fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
409                formatter.write_str("struct compactor.EchoResponse")
410            }
411
412            fn visit_map<V>(self, mut map_: V) -> std::result::Result<EchoResponse, V::Error>
413                where
414                    V: serde::de::MapAccess<'de>,
415            {
416                while map_.next_key::<GeneratedField>()?.is_some() {
417                    let _ = map_.next_value::<serde::de::IgnoredAny>()?;
418                }
419                Ok(EchoResponse {
420                })
421            }
422        }
423        deserializer.deserialize_struct("compactor.EchoResponse", FIELDS, GeneratedVisitor)
424    }
425}