datadog_api_client/datadogV2/model/
model_process_summaries_meta_page.rs1use serde::de::{Error, MapAccess, Visitor};
5use serde::{Deserialize, Deserializer, Serialize};
6use serde_with::skip_serializing_none;
7use std::fmt::{self, Formatter};
8
9#[non_exhaustive]
11#[skip_serializing_none]
12#[derive(Clone, Debug, PartialEq, Serialize)]
13pub struct ProcessSummariesMetaPage {
14 #[serde(rename = "after")]
17 pub after: Option<String>,
18 #[serde(rename = "size")]
20 pub size: Option<i32>,
21 #[serde(flatten)]
22 pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
23 #[serde(skip)]
24 #[serde(default)]
25 pub(crate) _unparsed: bool,
26}
27
28impl ProcessSummariesMetaPage {
29 pub fn new() -> ProcessSummariesMetaPage {
30 ProcessSummariesMetaPage {
31 after: None,
32 size: None,
33 additional_properties: std::collections::BTreeMap::new(),
34 _unparsed: false,
35 }
36 }
37
38 pub fn after(mut self, value: String) -> Self {
39 self.after = Some(value);
40 self
41 }
42
43 pub fn size(mut self, value: i32) -> Self {
44 self.size = Some(value);
45 self
46 }
47
48 pub fn additional_properties(
49 mut self,
50 value: std::collections::BTreeMap<String, serde_json::Value>,
51 ) -> Self {
52 self.additional_properties = value;
53 self
54 }
55}
56
57impl Default for ProcessSummariesMetaPage {
58 fn default() -> Self {
59 Self::new()
60 }
61}
62
63impl<'de> Deserialize<'de> for ProcessSummariesMetaPage {
64 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
65 where
66 D: Deserializer<'de>,
67 {
68 struct ProcessSummariesMetaPageVisitor;
69 impl<'a> Visitor<'a> for ProcessSummariesMetaPageVisitor {
70 type Value = ProcessSummariesMetaPage;
71
72 fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
73 f.write_str("a mapping")
74 }
75
76 fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
77 where
78 M: MapAccess<'a>,
79 {
80 let mut after: Option<String> = None;
81 let mut size: Option<i32> = None;
82 let mut additional_properties: std::collections::BTreeMap<
83 String,
84 serde_json::Value,
85 > = std::collections::BTreeMap::new();
86 let mut _unparsed = false;
87
88 while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
89 match k.as_str() {
90 "after" => {
91 if v.is_null() {
92 continue;
93 }
94 after = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
95 }
96 "size" => {
97 if v.is_null() {
98 continue;
99 }
100 size = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
101 }
102 &_ => {
103 if let Ok(value) = serde_json::from_value(v.clone()) {
104 additional_properties.insert(k, value);
105 }
106 }
107 }
108 }
109
110 let content = ProcessSummariesMetaPage {
111 after,
112 size,
113 additional_properties,
114 _unparsed,
115 };
116
117 Ok(content)
118 }
119 }
120
121 deserializer.deserialize_any(ProcessSummariesMetaPageVisitor)
122 }
123}