k8s_openapi/v1_34/api/storage/v1/
volume_error.rs

1// Generated from definition io.k8s.api.storage.v1.VolumeError
2
3/// VolumeError captures an error encountered during a volume operation.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct VolumeError {
6    /// errorCode is a numeric gRPC code representing the error encountered during Attach or Detach operations.
7    ///
8    /// This is an optional, beta field that requires the MutableCSINodeAllocatableCount feature gate being enabled to be set.
9    pub error_code: Option<i32>,
10
11    /// message represents the error encountered during Attach or Detach operation. This string may be logged, so it should not contain sensitive information.
12    pub message: Option<std::string::String>,
13
14    /// time represents the time the error was encountered.
15    pub time: Option<crate::apimachinery::pkg::apis::meta::v1::Time>,
16}
17
18impl crate::DeepMerge for VolumeError {
19    fn merge_from(&mut self, other: Self) {
20        crate::DeepMerge::merge_from(&mut self.error_code, other.error_code);
21        crate::DeepMerge::merge_from(&mut self.message, other.message);
22        crate::DeepMerge::merge_from(&mut self.time, other.time);
23    }
24}
25
26impl<'de> crate::serde::Deserialize<'de> for VolumeError {
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_error_code,
31            Key_message,
32            Key_time,
33            Other,
34        }
35
36        impl<'de> crate::serde::Deserialize<'de> for Field {
37            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38                struct Visitor;
39
40                impl crate::serde::de::Visitor<'_> for Visitor {
41                    type Value = Field;
42
43                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44                        f.write_str("field identifier")
45                    }
46
47                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
48                        Ok(match v {
49                            "errorCode" => Field::Key_error_code,
50                            "message" => Field::Key_message,
51                            "time" => Field::Key_time,
52                            _ => Field::Other,
53                        })
54                    }
55                }
56
57                deserializer.deserialize_identifier(Visitor)
58            }
59        }
60
61        struct Visitor;
62
63        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
64            type Value = VolumeError;
65
66            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67                f.write_str("VolumeError")
68            }
69
70            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
71                let mut value_error_code: Option<i32> = None;
72                let mut value_message: Option<std::string::String> = None;
73                let mut value_time: Option<crate::apimachinery::pkg::apis::meta::v1::Time> = None;
74
75                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
76                    match key {
77                        Field::Key_error_code => value_error_code = crate::serde::de::MapAccess::next_value(&mut map)?,
78                        Field::Key_message => value_message = crate::serde::de::MapAccess::next_value(&mut map)?,
79                        Field::Key_time => value_time = crate::serde::de::MapAccess::next_value(&mut map)?,
80                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
81                    }
82                }
83
84                Ok(VolumeError {
85                    error_code: value_error_code,
86                    message: value_message,
87                    time: value_time,
88                })
89            }
90        }
91
92        deserializer.deserialize_struct(
93            "VolumeError",
94            &[
95                "errorCode",
96                "message",
97                "time",
98            ],
99            Visitor,
100        )
101    }
102}
103
104impl crate::serde::Serialize for VolumeError {
105    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
106        let mut state = serializer.serialize_struct(
107            "VolumeError",
108            self.error_code.as_ref().map_or(0, |_| 1) +
109            self.message.as_ref().map_or(0, |_| 1) +
110            self.time.as_ref().map_or(0, |_| 1),
111        )?;
112        if let Some(value) = &self.error_code {
113            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "errorCode", value)?;
114        }
115        if let Some(value) = &self.message {
116            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "message", value)?;
117        }
118        if let Some(value) = &self.time {
119            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "time", value)?;
120        }
121        crate::serde::ser::SerializeStruct::end(state)
122    }
123}
124
125#[cfg(feature = "schemars")]
126impl crate::schemars::JsonSchema for VolumeError {
127    fn schema_name() -> std::borrow::Cow<'static, str> {
128        "io.k8s.api.storage.v1.VolumeError".into()
129    }
130
131    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
132        crate::schemars::json_schema!({
133            "description": "VolumeError captures an error encountered during a volume operation.",
134            "type": "object",
135            "properties": {
136                "errorCode": {
137                    "description": "errorCode is a numeric gRPC code representing the error encountered during Attach or Detach operations.\n\nThis is an optional, beta field that requires the MutableCSINodeAllocatableCount feature gate being enabled to be set.",
138                    "type": "integer",
139                    "format": "int32",
140                },
141                "message": {
142                    "description": "message represents the error encountered during Attach or Detach operation. This string may be logged, so it should not contain sensitive information.",
143                    "type": "string",
144                },
145                "time": ({
146                    let mut schema_obj = __gen.subschema_for::<crate::apimachinery::pkg::apis::meta::v1::Time>();
147                    schema_obj.ensure_object().insert("description".into(), "time represents the time the error was encountered.".into());
148                    schema_obj
149                }),
150            },
151        })
152    }
153}