k8s_openapi/v1_34/api/networking/v1beta1/
ip_address_spec.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct IPAddressSpec {
6 pub parent_ref: crate::api::networking::v1beta1::ParentReference,
8}
9
10impl crate::DeepMerge for IPAddressSpec {
11 fn merge_from(&mut self, other: Self) {
12 crate::DeepMerge::merge_from(&mut self.parent_ref, other.parent_ref);
13 }
14}
15
16impl<'de> crate::serde::Deserialize<'de> for IPAddressSpec {
17 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
18 #[allow(non_camel_case_types)]
19 enum Field {
20 Key_parent_ref,
21 Other,
22 }
23
24 impl<'de> crate::serde::Deserialize<'de> for Field {
25 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26 struct Visitor;
27
28 impl crate::serde::de::Visitor<'_> for Visitor {
29 type Value = Field;
30
31 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
32 f.write_str("field identifier")
33 }
34
35 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
36 Ok(match v {
37 "parentRef" => Field::Key_parent_ref,
38 _ => Field::Other,
39 })
40 }
41 }
42
43 deserializer.deserialize_identifier(Visitor)
44 }
45 }
46
47 struct Visitor;
48
49 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
50 type Value = IPAddressSpec;
51
52 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
53 f.write_str("IPAddressSpec")
54 }
55
56 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
57 let mut value_parent_ref: Option<crate::api::networking::v1beta1::ParentReference> = None;
58
59 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
60 match key {
61 Field::Key_parent_ref => value_parent_ref = crate::serde::de::MapAccess::next_value(&mut map)?,
62 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
63 }
64 }
65
66 Ok(IPAddressSpec {
67 parent_ref: value_parent_ref.unwrap_or_default(),
68 })
69 }
70 }
71
72 deserializer.deserialize_struct(
73 "IPAddressSpec",
74 &[
75 "parentRef",
76 ],
77 Visitor,
78 )
79 }
80}
81
82impl crate::serde::Serialize for IPAddressSpec {
83 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
84 let mut state = serializer.serialize_struct(
85 "IPAddressSpec",
86 1,
87 )?;
88 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "parentRef", &self.parent_ref)?;
89 crate::serde::ser::SerializeStruct::end(state)
90 }
91}
92
93#[cfg(feature = "schemars")]
94impl crate::schemars::JsonSchema for IPAddressSpec {
95 fn schema_name() -> std::borrow::Cow<'static, str> {
96 "io.k8s.api.networking.v1beta1.IPAddressSpec".into()
97 }
98
99 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
100 crate::schemars::json_schema!({
101 "description": "IPAddressSpec describe the attributes in an IP Address.",
102 "type": "object",
103 "properties": {
104 "parentRef": ({
105 let mut schema_obj = __gen.subschema_for::<crate::api::networking::v1beta1::ParentReference>();
106 schema_obj.ensure_object().insert("description".into(), "ParentRef references the resource that an IPAddress is attached to. An IPAddress must reference a parent object.".into());
107 schema_obj
108 }),
109 },
110 "required": [
111 "parentRef",
112 ],
113 })
114 }
115}