k8s_openapi/v1_32/api/node/v1/
overhead.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct Overhead {
6 pub pod_fixed: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>>,
8}
9
10impl crate::DeepMerge for Overhead {
11 fn merge_from(&mut self, other: Self) {
12 crate::merge_strategies::map::granular(&mut self.pod_fixed, other.pod_fixed, |current_item, other_item| {
13 crate::DeepMerge::merge_from(current_item, other_item);
14 });
15 }
16}
17
18impl<'de> crate::serde::Deserialize<'de> for Overhead {
19 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
20 #[allow(non_camel_case_types)]
21 enum Field {
22 Key_pod_fixed,
23 Other,
24 }
25
26 impl<'de> crate::serde::Deserialize<'de> for Field {
27 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28 struct Visitor;
29
30 impl crate::serde::de::Visitor<'_> for Visitor {
31 type Value = Field;
32
33 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 f.write_str("field identifier")
35 }
36
37 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
38 Ok(match v {
39 "podFixed" => Field::Key_pod_fixed,
40 _ => Field::Other,
41 })
42 }
43 }
44
45 deserializer.deserialize_identifier(Visitor)
46 }
47 }
48
49 struct Visitor;
50
51 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
52 type Value = Overhead;
53
54 fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55 f.write_str("Overhead")
56 }
57
58 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
59 let mut value_pod_fixed: Option<std::collections::BTreeMap<String, crate::apimachinery::pkg::api::resource::Quantity>> = None;
60
61 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
62 match key {
63 Field::Key_pod_fixed => value_pod_fixed = crate::serde::de::MapAccess::next_value(&mut map)?,
64 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
65 }
66 }
67
68 Ok(Overhead {
69 pod_fixed: value_pod_fixed,
70 })
71 }
72 }
73
74 deserializer.deserialize_struct(
75 "Overhead",
76 &[
77 "podFixed",
78 ],
79 Visitor,
80 )
81 }
82}
83
84impl crate::serde::Serialize for Overhead {
85 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
86 let mut state = serializer.serialize_struct(
87 "Overhead",
88 self.pod_fixed.as_ref().map_or(0, |_| 1),
89 )?;
90 if let Some(value) = &self.pod_fixed {
91 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podFixed", value)?;
92 }
93 crate::serde::ser::SerializeStruct::end(state)
94 }
95}
96
97#[cfg(feature = "schemars")]
98impl crate::schemars::JsonSchema for Overhead {
99 fn schema_name() -> String {
100 "io.k8s.api.node.v1.Overhead".to_owned()
101 }
102
103 fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
104 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
105 metadata: Some(Box::new(crate::schemars::schema::Metadata {
106 description: Some("Overhead structure represents the resource overhead associated with running a pod.".to_owned()),
107 ..Default::default()
108 })),
109 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
110 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
111 properties: [
112 (
113 "podFixed".to_owned(),
114 crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
115 metadata: Some(Box::new(crate::schemars::schema::Metadata {
116 description: Some("podFixed represents the fixed resource overhead associated with running a pod.".to_owned()),
117 ..Default::default()
118 })),
119 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
120 object: Some(Box::new(crate::schemars::schema::ObjectValidation {
121 additional_properties: Some(Box::new(__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>())),
122 ..Default::default()
123 })),
124 ..Default::default()
125 }),
126 ),
127 ].into(),
128 ..Default::default()
129 })),
130 ..Default::default()
131 })
132 }
133}