k8s_openapi/v1_34/api/resource/v1beta1/
device_claim_configuration.rs1#[derive(Clone, Debug, Default, PartialEq)]
5pub struct DeviceClaimConfiguration {
6 pub opaque: Option<crate::api::resource::v1beta1::OpaqueDeviceConfiguration>,
8
9 pub requests: Option<std::vec::Vec<std::string::String>>,
13}
14
15impl crate::DeepMerge for DeviceClaimConfiguration {
16 fn merge_from(&mut self, other: Self) {
17 crate::DeepMerge::merge_from(&mut self.opaque, other.opaque);
18 crate::merge_strategies::list::atomic(&mut self.requests, other.requests);
19 }
20}
21
22impl<'de> crate::serde::Deserialize<'de> for DeviceClaimConfiguration {
23 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
24 #[allow(non_camel_case_types)]
25 enum Field {
26 Key_opaque,
27 Key_requests,
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 crate::serde::de::Visitor<'_> for Visitor {
36 type Value = Field;
37
38 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::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 "opaque" => Field::Key_opaque,
45 "requests" => Field::Key_requests,
46 _ => Field::Other,
47 })
48 }
49 }
50
51 deserializer.deserialize_identifier(Visitor)
52 }
53 }
54
55 struct Visitor;
56
57 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
58 type Value = DeviceClaimConfiguration;
59
60 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
61 f.write_str("DeviceClaimConfiguration")
62 }
63
64 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
65 let mut value_opaque: Option<crate::api::resource::v1beta1::OpaqueDeviceConfiguration> = None;
66 let mut value_requests: Option<std::vec::Vec<std::string::String>> = None;
67
68 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
69 match key {
70 Field::Key_opaque => value_opaque = crate::serde::de::MapAccess::next_value(&mut map)?,
71 Field::Key_requests => value_requests = crate::serde::de::MapAccess::next_value(&mut map)?,
72 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
73 }
74 }
75
76 Ok(DeviceClaimConfiguration {
77 opaque: value_opaque,
78 requests: value_requests,
79 })
80 }
81 }
82
83 deserializer.deserialize_struct(
84 "DeviceClaimConfiguration",
85 &[
86 "opaque",
87 "requests",
88 ],
89 Visitor,
90 )
91 }
92}
93
94impl crate::serde::Serialize for DeviceClaimConfiguration {
95 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
96 let mut state = serializer.serialize_struct(
97 "DeviceClaimConfiguration",
98 self.opaque.as_ref().map_or(0, |_| 1) +
99 self.requests.as_ref().map_or(0, |_| 1),
100 )?;
101 if let Some(value) = &self.opaque {
102 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "opaque", value)?;
103 }
104 if let Some(value) = &self.requests {
105 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "requests", value)?;
106 }
107 crate::serde::ser::SerializeStruct::end(state)
108 }
109}
110
111#[cfg(feature = "schemars")]
112impl crate::schemars::JsonSchema for DeviceClaimConfiguration {
113 fn schema_name() -> std::borrow::Cow<'static, str> {
114 "io.k8s.api.resource.v1beta1.DeviceClaimConfiguration".into()
115 }
116
117 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
118 crate::schemars::json_schema!({
119 "description": "DeviceClaimConfiguration is used for configuration parameters in DeviceClaim.",
120 "type": "object",
121 "properties": {
122 "opaque": ({
123 let mut schema_obj = __gen.subschema_for::<crate::api::resource::v1beta1::OpaqueDeviceConfiguration>();
124 schema_obj.ensure_object().insert("description".into(), "Opaque provides driver-specific configuration parameters.".into());
125 schema_obj
126 }),
127 "requests": {
128 "description": "Requests lists the names of requests where the configuration applies. If empty, it applies to all requests.\n\nReferences to subrequests must include the name of the main request and may include the subrequest using the format <main request>[/<subrequest>]. If just the main request is given, the configuration applies to all subrequests.",
129 "type": "array",
130 "items": {
131 "type": "string",
132 },
133 },
134 },
135 })
136 }
137}