1// Generated from definition io.k8s.api.storage.v1.VolumeNodeResources
23/// VolumeNodeResources is a set of resource limits for scheduling of volumes.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeNodeResources {
6/// count indicates the maximum number of unique volumes managed by the CSI driver that can be used on a node. A volume that is both attached and mounted on a node is considered to be used once, not twice. The same rule applies for a unique volume that is shared among multiple pods on the same node. If this field is not specified, then the supported number of volumes on this node is unbounded.
7pub count: Option<i32>,
8}
910impl crate::DeepMerge for VolumeNodeResources {
11fn merge_from(&mut self, other: Self) {
12crate::DeepMerge::merge_from(&mut self.count, other.count);
13 }
14}
1516impl<'de> crate::serde::Deserialize<'de> for VolumeNodeResources {
17fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
18#[allow(non_camel_case_types)]
19enum Field {
20 Key_count,
21 Other,
22 }
2324impl<'de> crate::serde::Deserialize<'de> for Field {
25fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
26struct Visitor;
2728impl crate::serde::de::Visitor<'_> for Visitor {
29type Value = Field;
3031fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
32 f.write_str("field identifier")
33 }
3435fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
36Ok(match v {
37"count" => Field::Key_count,
38_ => Field::Other,
39 })
40 }
41 }
4243 deserializer.deserialize_identifier(Visitor)
44 }
45 }
4647struct Visitor;
4849impl<'de> crate::serde::de::Visitor<'de> for Visitor {
50type Value = VolumeNodeResources;
5152fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
53 f.write_str("VolumeNodeResources")
54 }
5556fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
57let mut value_count: Option<i32> = None;
5859while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
60match key {
61 Field::Key_count => value_count = 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 }
6566Ok(VolumeNodeResources {
67 count: value_count,
68 })
69 }
70 }
7172 deserializer.deserialize_struct(
73"VolumeNodeResources",
74&[
75"count",
76 ],
77 Visitor,
78 )
79 }
80}
8182impl crate::serde::Serialize for VolumeNodeResources {
83fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
84let mut state = serializer.serialize_struct(
85"VolumeNodeResources",
86self.count.as_ref().map_or(0, |_| 1),
87 )?;
88if let Some(value) = &self.count {
89crate::serde::ser::SerializeStruct::serialize_field(&mut state, "count", value)?;
90 }
91crate::serde::ser::SerializeStruct::end(state)
92 }
93}
9495#[cfg(feature = "schemars")]
96impl crate::schemars::JsonSchema for VolumeNodeResources {
97fn schema_name() -> std::string::String {
98"io.k8s.api.storage.v1.VolumeNodeResources".into()
99 }
100101fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
102crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
103 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
104 description: Some("VolumeNodeResources is a set of resource limits for scheduling of volumes.".into()),
105 ..Default::default()
106 })),
107 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Object))),
108 object: Some(std::boxed::Box::new(crate::schemars::schema::ObjectValidation {
109 properties: [
110 (
111"count".into(),
112crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
113 metadata: Some(std::boxed::Box::new(crate::schemars::schema::Metadata {
114 description: Some("count indicates the maximum number of unique volumes managed by the CSI driver that can be used on a node. A volume that is both attached and mounted on a node is considered to be used once, not twice. The same rule applies for a unique volume that is shared among multiple pods on the same node. If this field is not specified, then the supported number of volumes on this node is unbounded.".into()),
115 ..Default::default()
116 })),
117 instance_type: Some(crate::schemars::schema::SingleOrVec::Single(std::boxed::Box::new(crate::schemars::schema::InstanceType::Integer))),
118 format: Some("int32".into()),
119 ..Default::default()
120 }),
121 ),
122 ].into(),
123 ..Default::default()
124 })),
125 ..Default::default()
126 })
127 }
128}