#
k8s_openapi/v1_35/api/networking/v1/
ingress_port_status.rs

    1// Generated from definition io.k8s.api.networking.v1.IngressPortStatus
    2
    3/// IngressPortStatus represents the error condition of a service port
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct IngressPortStatus {
    6    /// error is to record the problem with the service port The format of the error shall comply with the following rules: - built-in error values shall be specified in this file and those shall use
    7    ///   CamelCase names
    8    /// - cloud provider specific error values must have names that comply with the
    9    ///   format foo.example.com/CamelCase.
    10    pub error: Option<std::string::String>,
    11
    12    /// port is the port number of the ingress port.
    13    pub port: i32,
    14
    15    /// protocol is the protocol of the ingress port. The supported values are: "TCP", "UDP", "SCTP"
    16    pub protocol: std::string::String,
    17}
    18
    19impl crate::DeepMerge for IngressPortStatus {
    20    fn merge_from(&mut self, other: Self) {
    21        crate::DeepMerge::merge_from(&mut self.error, other.error);
    22        crate::DeepMerge::merge_from(&mut self.port, other.port);
    23        crate::DeepMerge::merge_from(&mut self.protocol, other.protocol);
    24    }
    25}
    26
    27impl<'de> crate::serde::Deserialize<'de> for IngressPortStatus {
    28    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    29        #[allow(non_camel_case_types)]
    30        enum Field {
    31            Key_error,
    32            Key_port,
    33            Key_protocol,
    34            Other,
    35        }
    36
    37        impl<'de> crate::serde::Deserialize<'de> for Field {
    38            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    39                struct Visitor;
    40
    41                impl crate::serde::de::Visitor<'_> for Visitor {
    42                    type Value = Field;
    43
    44                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    45                        f.write_str("field identifier")
    46                    }
    47
    48                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    49                        Ok(match v {
    50                            "error" => Field::Key_error,
    51                            "port" => Field::Key_port,
    52                            "protocol" => Field::Key_protocol,
    53                            _ => Field::Other,
    54                        })
    55                    }
    56                }
    57
    58                deserializer.deserialize_identifier(Visitor)
    59            }
    60        }
    61
    62        struct Visitor;
    63
    64        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
    65            type Value = IngressPortStatus;
    66
    67            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    68                f.write_str("IngressPortStatus")
    69            }
    70
    71            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
    72                let mut value_error: Option<std::string::String> = None;
    73                let mut value_port: Option<i32> = None;
    74                let mut value_protocol: Option<std::string::String> = None;
    75
    76                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    77                    match key {
    78                        Field::Key_error => value_error = crate::serde::de::MapAccess::next_value(&mut map)?,
    79                        Field::Key_port => value_port = crate::serde::de::MapAccess::next_value(&mut map)?,
    80                        Field::Key_protocol => value_protocol = crate::serde::de::MapAccess::next_value(&mut map)?,
    81                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    82                    }
    83                }
    84
    85                Ok(IngressPortStatus {
    86                    error: value_error,
    87                    port: value_port.unwrap_or_default(),
    88                    protocol: value_protocol.unwrap_or_default(),
    89                })
    90            }
    91        }
    92
    93        deserializer.deserialize_struct(
    94            "IngressPortStatus",
    95            &[
    96                "error",
    97                "port",
    98                "protocol",
    99            ],
    100            Visitor,
    101        )
    102    }
    103}
    104
    105impl crate::serde::Serialize for IngressPortStatus {
    106    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    107        let mut state = serializer.serialize_struct(
    108            "IngressPortStatus",
    109            2 +
    110            self.error.as_ref().map_or(0, |_| 1),
    111        )?;
    112        if let Some(value) = &self.error {
    113            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "error", value)?;
    114        }
    115        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "port", &self.port)?;
    116        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "protocol", &self.protocol)?;
    117        crate::serde::ser::SerializeStruct::end(state)
    118    }
    119}
    120
    121#[cfg(feature = "schemars")]
    122impl crate::schemars::JsonSchema for IngressPortStatus {
    123    fn schema_name() -> std::borrow::Cow<'static, str> {
    124        "io.k8s.api.networking.v1.IngressPortStatus".into()
    125    }
    126
    127    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    128        crate::schemars::json_schema!({
    129            "description": "IngressPortStatus represents the error condition of a service port",
    130            "type": "object",
    131            "properties": {
    132                "error": {
    133                    "description": "error is to record the problem with the service port The format of the error shall comply with the following rules: - built-in error values shall be specified in this file and those shall use\n  CamelCase names\n- cloud provider specific error values must have names that comply with the\n  format foo.example.com/CamelCase.",
    134                    "type": "string",
    135                },
    136                "port": {
    137                    "description": "port is the port number of the ingress port.",
    138                    "type": "integer",
    139                    "format": "int32",
    140                },
    141                "protocol": {
    142                    "description": "protocol is the protocol of the ingress port. The supported values are: \"TCP\", \"UDP\", \"SCTP\"",
    143                    "type": "string",
    144                },
    145            },
    146            "required": [
    147                "port",
    148                "protocol",
    149            ],
    150        })
    151    }
    152}