#
k8s_openapi/v1_35/api/node/v1/
overhead.rs

    1// Generated from definition io.k8s.api.node.v1.Overhead
    2
    3/// Overhead structure represents the resource overhead associated with running a pod.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct Overhead {
    6    /// podFixed represents the fixed resource overhead associated with running a pod.
    7    pub pod_fixed: Option<std::collections::BTreeMap<std::string::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 core::fmt::Formatter<'_>) -> core::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 core::fmt::Formatter<'_>) -> core::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<std::string::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() -> std::borrow::Cow<'static, str> {
    100        "io.k8s.api.node.v1.Overhead".into()
    101    }
    102
    103    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    104        crate::schemars::json_schema!({
    105            "description": "Overhead structure represents the resource overhead associated with running a pod.",
    106            "type": "object",
    107            "properties": {
    108                "podFixed": {
    109                    "description": "podFixed represents the fixed resource overhead associated with running a pod.",
    110                    "type": "object",
    111                    "additionalProperties": (__gen.subschema_for::<crate::apimachinery::pkg::api::resource::Quantity>()),
    112                },
    113            },
    114        })
    115    }
    116}