k8s_openapi/v1_30/api/flowcontrol/v1beta3/
flow_schema_status.rs

1// Generated from definition io.k8s.api.flowcontrol.v1beta3.FlowSchemaStatus
2
3/// FlowSchemaStatus represents the current state of a FlowSchema.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct FlowSchemaStatus {
6    /// `conditions` is a list of the current states of FlowSchema.
7    pub conditions: Option<Vec<crate::api::flowcontrol::v1beta3::FlowSchemaCondition>>,
8}
9
10impl crate::DeepMerge for FlowSchemaStatus {
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 FlowSchemaStatus {
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<'de> crate::serde::de::Visitor<'de> for Visitor {
36                    type Value = Field;
37
38                    fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::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 = FlowSchemaStatus;
58
59            fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60                f.write_str("FlowSchemaStatus")
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<Vec<crate::api::flowcontrol::v1beta3::FlowSchemaCondition>> = 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(FlowSchemaStatus {
74                    conditions: value_conditions,
75                })
76            }
77        }
78
79        deserializer.deserialize_struct(
80            "FlowSchemaStatus",
81            &[
82                "conditions",
83            ],
84            Visitor,
85        )
86    }
87}
88
89impl crate::serde::Serialize for FlowSchemaStatus {
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            "FlowSchemaStatus",
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 FlowSchemaStatus {
104    fn schema_name() -> String {
105        "io.k8s.api.flowcontrol.v1beta3.FlowSchemaStatus".to_owned()
106    }
107
108    fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
109        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
110            metadata: Some(Box::new(crate::schemars::schema::Metadata {
111                description: Some("FlowSchemaStatus represents the current state of a FlowSchema.".to_owned()),
112                ..Default::default()
113            })),
114            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
115            object: Some(Box::new(crate::schemars::schema::ObjectValidation {
116                properties: [
117                    (
118                        "conditions".to_owned(),
119                        crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
120                            metadata: Some(Box::new(crate::schemars::schema::Metadata {
121                                description: Some("`conditions` is a list of the current states of FlowSchema.".to_owned()),
122                                ..Default::default()
123                            })),
124                            instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Array))),
125                            array: Some(Box::new(crate::schemars::schema::ArrayValidation {
126                                items: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(__gen.subschema_for::<crate::api::flowcontrol::v1beta3::FlowSchemaCondition>()))),
127                                ..Default::default()
128                            })),
129                            ..Default::default()
130                        }),
131                    ),
132                ].into(),
133                ..Default::default()
134            })),
135            ..Default::default()
136        })
137    }
138}