openshift_openapi/v4_5/api/route/v1/
route_ingress.rs

1// Generated from definition com.github.openshift.api.route.v1.RouteIngress
2
3/// RouteIngress holds information about the places where a route is exposed.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct RouteIngress {
6    /// Conditions is the state of the route, may be empty.
7    pub conditions: Option<Vec<crate::api::route::v1::RouteIngressCondition>>,
8
9    /// Host is the host string under which the route is exposed; this value is required
10    pub host: Option<String>,
11
12    /// CanonicalHostname is the external host name for the router that can be used as a CNAME for the host requested for this route. This value is optional and may not be set in all cases.
13    pub router_canonical_hostname: Option<String>,
14
15    /// Name is a name chosen by the router to identify itself; this value is required
16    pub router_name: Option<String>,
17
18    /// Wildcard policy is the wildcard policy that was allowed where this route is exposed.
19    pub wildcard_policy: Option<String>,
20}
21
22impl<'de> serde::Deserialize<'de> for RouteIngress {
23    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
24        #[allow(non_camel_case_types)]
25        enum Field {
26            Key_conditions,
27            Key_host,
28            Key_router_canonical_hostname,
29            Key_router_name,
30            Key_wildcard_policy,
31            Other,
32        }
33
34        impl<'de> serde::Deserialize<'de> for Field {
35            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'de> {
36                struct Visitor;
37
38                impl<'de> serde::de::Visitor<'de> for Visitor {
39                    type Value = Field;
40
41                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42                        f.write_str("field identifier")
43                    }
44
45                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: serde::de::Error {
46                        Ok(match v {
47                            "conditions" => Field::Key_conditions,
48                            "host" => Field::Key_host,
49                            "routerCanonicalHostname" => Field::Key_router_canonical_hostname,
50                            "routerName" => Field::Key_router_name,
51                            "wildcardPolicy" => Field::Key_wildcard_policy,
52                            _ => Field::Other,
53                        })
54                    }
55                }
56
57                deserializer.deserialize_identifier(Visitor)
58            }
59        }
60
61        struct Visitor;
62
63        impl<'de> serde::de::Visitor<'de> for Visitor {
64            type Value = RouteIngress;
65
66            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
67                f.write_str("RouteIngress")
68            }
69
70            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: serde::de::MapAccess<'de> {
71                let mut value_conditions: Option<Vec<crate::api::route::v1::RouteIngressCondition>> = None;
72                let mut value_host: Option<String> = None;
73                let mut value_router_canonical_hostname: Option<String> = None;
74                let mut value_router_name: Option<String> = None;
75                let mut value_wildcard_policy: Option<String> = None;
76
77                while let Some(key) = serde::de::MapAccess::next_key::<Field>(&mut map)? {
78                    match key {
79                        Field::Key_conditions => value_conditions = serde::de::MapAccess::next_value(&mut map)?,
80                        Field::Key_host => value_host = serde::de::MapAccess::next_value(&mut map)?,
81                        Field::Key_router_canonical_hostname => value_router_canonical_hostname = serde::de::MapAccess::next_value(&mut map)?,
82                        Field::Key_router_name => value_router_name = serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_wildcard_policy => value_wildcard_policy = serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Other => { let _: serde::de::IgnoredAny = serde::de::MapAccess::next_value(&mut map)?; },
85                    }
86                }
87
88                Ok(RouteIngress {
89                    conditions: value_conditions,
90                    host: value_host,
91                    router_canonical_hostname: value_router_canonical_hostname,
92                    router_name: value_router_name,
93                    wildcard_policy: value_wildcard_policy,
94                })
95            }
96        }
97
98        deserializer.deserialize_struct(
99            "RouteIngress",
100            &[
101                "conditions",
102                "host",
103                "routerCanonicalHostname",
104                "routerName",
105                "wildcardPolicy",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl serde::Serialize for RouteIngress {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "RouteIngress",
116            self.conditions.as_ref().map_or(0, |_| 1) +
117            self.host.as_ref().map_or(0, |_| 1) +
118            self.router_canonical_hostname.as_ref().map_or(0, |_| 1) +
119            self.router_name.as_ref().map_or(0, |_| 1) +
120            self.wildcard_policy.as_ref().map_or(0, |_| 1),
121        )?;
122        if let Some(value) = &self.conditions {
123            serde::ser::SerializeStruct::serialize_field(&mut state, "conditions", value)?;
124        }
125        if let Some(value) = &self.host {
126            serde::ser::SerializeStruct::serialize_field(&mut state, "host", value)?;
127        }
128        if let Some(value) = &self.router_canonical_hostname {
129            serde::ser::SerializeStruct::serialize_field(&mut state, "routerCanonicalHostname", value)?;
130        }
131        if let Some(value) = &self.router_name {
132            serde::ser::SerializeStruct::serialize_field(&mut state, "routerName", value)?;
133        }
134        if let Some(value) = &self.wildcard_policy {
135            serde::ser::SerializeStruct::serialize_field(&mut state, "wildcardPolicy", value)?;
136        }
137        serde::ser::SerializeStruct::end(state)
138    }
139}