k8s_openapi/v1_30/api/core/v1/
claim_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
7pub struct ClaimSource {
8 pub resource_claim_name: Option<std::string::String>,
10
11 pub resource_claim_template_name: Option<std::string::String>,
17}
18
19impl crate::DeepMerge for ClaimSource {
20 fn merge_from(&mut self, other: Self) {
21 crate::DeepMerge::merge_from(&mut self.resource_claim_name, other.resource_claim_name);
22 crate::DeepMerge::merge_from(&mut self.resource_claim_template_name, other.resource_claim_template_name);
23 }
24}
25
26impl<'de> crate::serde::Deserialize<'de> for ClaimSource {
27 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28 #[allow(non_camel_case_types)]
29 enum Field {
30 Key_resource_claim_name,
31 Key_resource_claim_template_name,
32 Other,
33 }
34
35 impl<'de> crate::serde::Deserialize<'de> for Field {
36 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
37 struct Visitor;
38
39 impl crate::serde::de::Visitor<'_> for Visitor {
40 type Value = Field;
41
42 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
43 f.write_str("field identifier")
44 }
45
46 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
47 Ok(match v {
48 "resourceClaimName" => Field::Key_resource_claim_name,
49 "resourceClaimTemplateName" => Field::Key_resource_claim_template_name,
50 _ => Field::Other,
51 })
52 }
53 }
54
55 deserializer.deserialize_identifier(Visitor)
56 }
57 }
58
59 struct Visitor;
60
61 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
62 type Value = ClaimSource;
63
64 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 f.write_str("ClaimSource")
66 }
67
68 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
69 let mut value_resource_claim_name: Option<std::string::String> = None;
70 let mut value_resource_claim_template_name: Option<std::string::String> = None;
71
72 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
73 match key {
74 Field::Key_resource_claim_name => value_resource_claim_name = crate::serde::de::MapAccess::next_value(&mut map)?,
75 Field::Key_resource_claim_template_name => value_resource_claim_template_name = crate::serde::de::MapAccess::next_value(&mut map)?,
76 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
77 }
78 }
79
80 Ok(ClaimSource {
81 resource_claim_name: value_resource_claim_name,
82 resource_claim_template_name: value_resource_claim_template_name,
83 })
84 }
85 }
86
87 deserializer.deserialize_struct(
88 "ClaimSource",
89 &[
90 "resourceClaimName",
91 "resourceClaimTemplateName",
92 ],
93 Visitor,
94 )
95 }
96}
97
98impl crate::serde::Serialize for ClaimSource {
99 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
100 let mut state = serializer.serialize_struct(
101 "ClaimSource",
102 self.resource_claim_name.as_ref().map_or(0, |_| 1) +
103 self.resource_claim_template_name.as_ref().map_or(0, |_| 1),
104 )?;
105 if let Some(value) = &self.resource_claim_name {
106 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimName", value)?;
107 }
108 if let Some(value) = &self.resource_claim_template_name {
109 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceClaimTemplateName", value)?;
110 }
111 crate::serde::ser::SerializeStruct::end(state)
112 }
113}
114
115#[cfg(feature = "schemars")]
116impl crate::schemars::JsonSchema for ClaimSource {
117 fn schema_name() -> std::borrow::Cow<'static, str> {
118 "io.k8s.api.core.v1.ClaimSource".into()
119 }
120
121 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
122 crate::schemars::json_schema!({
123 "description": "ClaimSource describes a reference to a ResourceClaim.\n\nExactly one of these fields should be set. Consumers of this type must treat an empty object as if it has an unknown value.",
124 "type": "object",
125 "properties": {
126 "resourceClaimName": {
127 "description": "ResourceClaimName is the name of a ResourceClaim object in the same namespace as this pod.",
128 "type": "string",
129 },
130 "resourceClaimTemplateName": {
131 "description": "ResourceClaimTemplateName is the name of a ResourceClaimTemplate object in the same namespace as this pod.\n\nThe template will be used to create a new ResourceClaim, which will be bound to this pod. When this pod is deleted, the ResourceClaim will also be deleted. The pod name and resource name, along with a generated component, will be used to form a unique name for the ResourceClaim, which will be recorded in pod.status.resourceClaimStatuses.\n\nThis field is immutable and no changes will be made to the corresponding ResourceClaim by the control plane after creating the ResourceClaim.",
132 "type": "string",
133 },
134 },
135 })
136 }
137}