k8s_openapi/v1_35/api/core/v1/
volume_mount_status.rs

1// Generated from definition io.k8s.api.core.v1.VolumeMountStatus
2
3/// VolumeMountStatus shows status of volume mounts.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeMountStatus {
6    /// MountPath corresponds to the original VolumeMount.
7    pub mount_path: std::string::String,
8
9    /// Name corresponds to the name of the original VolumeMount.
10    pub name: std::string::String,
11
12    /// ReadOnly corresponds to the original VolumeMount.
13    pub read_only: Option<bool>,
14
15    /// RecursiveReadOnly must be set to Disabled, Enabled, or unspecified (for non-readonly mounts). An IfPossible value in the original VolumeMount must be translated to Disabled or Enabled, depending on the mount result.
16    pub recursive_read_only: Option<std::string::String>,
17}
18
19impl crate::DeepMerge for VolumeMountStatus {
20    fn merge_from(&mut self, other: Self) {
21        crate::DeepMerge::merge_from(&mut self.mount_path, other.mount_path);
22        crate::DeepMerge::merge_from(&mut self.name, other.name);
23        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
24        crate::DeepMerge::merge_from(&mut self.recursive_read_only, other.recursive_read_only);
25    }
26}
27
28impl<'de> crate::serde::Deserialize<'de> for VolumeMountStatus {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
30        #[allow(non_camel_case_types)]
31        enum Field {
32            Key_mount_path,
33            Key_name,
34            Key_read_only,
35            Key_recursive_read_only,
36            Other,
37        }
38
39        impl<'de> crate::serde::Deserialize<'de> for Field {
40            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
41                struct Visitor;
42
43                impl crate::serde::de::Visitor<'_> for Visitor {
44                    type Value = Field;
45
46                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
47                        f.write_str("field identifier")
48                    }
49
50                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
51                        Ok(match v {
52                            "mountPath" => Field::Key_mount_path,
53                            "name" => Field::Key_name,
54                            "readOnly" => Field::Key_read_only,
55                            "recursiveReadOnly" => Field::Key_recursive_read_only,
56                            _ => Field::Other,
57                        })
58                    }
59                }
60
61                deserializer.deserialize_identifier(Visitor)
62            }
63        }
64
65        struct Visitor;
66
67        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
68            type Value = VolumeMountStatus;
69
70            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
71                f.write_str("VolumeMountStatus")
72            }
73
74            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
75                let mut value_mount_path: Option<std::string::String> = None;
76                let mut value_name: Option<std::string::String> = None;
77                let mut value_read_only: Option<bool> = None;
78                let mut value_recursive_read_only: Option<std::string::String> = None;
79
80                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
81                    match key {
82                        Field::Key_mount_path => value_mount_path = crate::serde::de::MapAccess::next_value(&mut map)?,
83                        Field::Key_name => value_name = crate::serde::de::MapAccess::next_value(&mut map)?,
84                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
85                        Field::Key_recursive_read_only => value_recursive_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
86                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
87                    }
88                }
89
90                Ok(VolumeMountStatus {
91                    mount_path: value_mount_path.unwrap_or_default(),
92                    name: value_name.unwrap_or_default(),
93                    read_only: value_read_only,
94                    recursive_read_only: value_recursive_read_only,
95                })
96            }
97        }
98
99        deserializer.deserialize_struct(
100            "VolumeMountStatus",
101            &[
102                "mountPath",
103                "name",
104                "readOnly",
105                "recursiveReadOnly",
106            ],
107            Visitor,
108        )
109    }
110}
111
112impl crate::serde::Serialize for VolumeMountStatus {
113    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
114        let mut state = serializer.serialize_struct(
115            "VolumeMountStatus",
116            2 +
117            self.read_only.as_ref().map_or(0, |_| 1) +
118            self.recursive_read_only.as_ref().map_or(0, |_| 1),
119        )?;
120        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "mountPath", &self.mount_path)?;
121        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "name", &self.name)?;
122        if let Some(value) = &self.read_only {
123            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
124        }
125        if let Some(value) = &self.recursive_read_only {
126            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "recursiveReadOnly", value)?;
127        }
128        crate::serde::ser::SerializeStruct::end(state)
129    }
130}
131
132#[cfg(feature = "schemars")]
133impl crate::schemars::JsonSchema for VolumeMountStatus {
134    fn schema_name() -> std::borrow::Cow<'static, str> {
135        "io.k8s.api.core.v1.VolumeMountStatus".into()
136    }
137
138    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
139        crate::schemars::json_schema!({
140            "description": "VolumeMountStatus shows status of volume mounts.",
141            "type": "object",
142            "properties": {
143                "mountPath": {
144                    "description": "MountPath corresponds to the original VolumeMount.",
145                    "type": "string",
146                },
147                "name": {
148                    "description": "Name corresponds to the name of the original VolumeMount.",
149                    "type": "string",
150                },
151                "readOnly": {
152                    "description": "ReadOnly corresponds to the original VolumeMount.",
153                    "type": "boolean",
154                },
155                "recursiveReadOnly": {
156                    "description": "RecursiveReadOnly must be set to Disabled, Enabled, or unspecified (for non-readonly mounts). An IfPossible value in the original VolumeMount must be translated to Disabled or Enabled, depending on the mount result.",
157                    "type": "string",
158                },
159            },
160            "required": [
161                "mountPath",
162                "name",
163            ],
164        })
165    }
166}