#
k8s_openapi/v1_35/api/networking/v1beta1/
service_cidr_status.rs

    1// Generated from definition io.k8s.api.networking.v1beta1.ServiceCIDRStatus
    2
    3/// ServiceCIDRStatus describes the current state of the ServiceCIDR.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ServiceCIDRStatus {
    6    /// conditions holds an array of metav1.Condition that describe the state of the ServiceCIDR. Current service state
    7    pub conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>>,
    8}
    9
    10impl crate::DeepMerge for ServiceCIDRStatus {
    11    fn merge_from(&mut self, other: Self) {
    12        crate::merge_strategies::list::map(
    13            &mut self.conditions,
    14            other.conditions,
    15            &[|lhs, rhs| lhs.type_ == rhs.type_],
    16            |current_item, other_item| {
    17                crate::DeepMerge::merge_from(current_item, other_item);
    18            },
    19        );
    20    }
    21}
    22
    23impl<'de> crate::serde::Deserialize<'de> for ServiceCIDRStatus {
    24    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    25        #[allow(non_camel_case_types)]
    26        enum Field {
    27            Key_conditions,
    28            Other,
    29        }
    30
    31        impl<'de> crate::serde::Deserialize<'de> for Field {
    32            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    33                struct Visitor;
    34
    35                impl crate::serde::de::Visitor<'_> for Visitor {
    36                    type Value = Field;
    37
    38                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    39                        f.write_str("field identifier")
    40                    }
    41
    42                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    43                        Ok(match v {
    44                            "conditions" => Field::Key_conditions,
    45                            _ => Field::Other,
    46                        })
    47                    }
    48                }
    49
    50                deserializer.deserialize_identifier(Visitor)
    51            }
    52        }
    53
    54        struct Visitor;
    55
    56        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    57            type Value = ServiceCIDRStatus;
    58
    59            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    60                f.write_str("ServiceCIDRStatus")
    61            }
    62
    63            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    64                let mut value_conditions: Option<std::vec::Vec<crate::apimachinery::pkg::apis::meta::v1::Condition>> = None;
    65
    66                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    67                    match key {
    68                        Field::Key_conditions => value_conditions = crate::serde::de::MapAccess::next_value(&mut map)?,
    69                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    70                    }
    71                }
    72
    73                Ok(ServiceCIDRStatus {
    74                    conditions: value_conditions,
    75                })
    76            }
    77        }
    78
    79        deserializer.deserialize_struct(
    80            "ServiceCIDRStatus",
    81            &[
    82                "conditions",
    83            ],
    84            Visitor,
    85        )
    86    }
    87}
    88
    89impl crate::serde::Serialize for ServiceCIDRStatus {
    90    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    91        let mut state = serializer.serialize_struct(
    92            "ServiceCIDRStatus",
    93            self.conditions.as_ref().map_or(0, |_| 1),
    94        )?;
    95        if let Some(value) = &self.conditions {
    96            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
    97        }
    98        crate::serde::ser::SerializeStruct::end(state)
    99    }
    100}
    101
    102#[cfg(feature = "schemars")]
    103impl crate::schemars::JsonSchema for ServiceCIDRStatus {
    104    fn schema_name() -> std::borrow::Cow<'static, str> {
    105        "io.k8s.api.networking.v1beta1.ServiceCIDRStatus".into()
    106    }
    107
    108    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    109        crate::schemars::json_schema!({
    110            "description": "ServiceCIDRStatus describes the current state of the ServiceCIDR.",
    111            "type": "object",
    112            "properties": {
    113                "conditions": {
    114                    "description": "conditions holds an array of metav1.Condition that describe the state of the ServiceCIDR. Current service state",
    115                    "type": "array",
    116                    "items": (__gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Condition>()),
    117                },
    118            },
    119        })
    120    }
    121}