#
k8s_openapi/v1_35/api/core/v1/
portworx_volume_source.rs

    1// Generated from definition io.k8s.api.core.v1.PortworxVolumeSource
    2
    3/// PortworxVolumeSource represents a Portworx volume resource.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct PortworxVolumeSource {
    6    /// fSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs". Implicitly inferred to be "ext4" if unspecified.
    7    pub fs_type: Option<std::string::String>,
    8
    9    /// readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.
    10    pub read_only: Option<bool>,
    11
    12    /// volumeID uniquely identifies a Portworx volume
    13    pub volume_id: std::string::String,
    14}
    15
    16impl crate::DeepMerge for PortworxVolumeSource {
    17    fn merge_from(&mut self, other: Self) {
    18        crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
    19        crate::DeepMerge::merge_from(&mut self.read_only, other.read_only);
    20        crate::DeepMerge::merge_from(&mut self.volume_id, other.volume_id);
    21    }
    22}
    23
    24impl<'de> crate::serde::Deserialize<'de> for PortworxVolumeSource {
    25    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    26        #[allow(non_camel_case_types)]
    27        enum Field {
    28            Key_fs_type,
    29            Key_read_only,
    30            Key_volume_id,
    31            Other,
    32        }
    33
    34        impl<'de> crate::serde::Deserialize<'de> for Field {
    35            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
    36                struct Visitor;
    37
    38                impl crate::serde::de::Visitor<'_> for Visitor {
    39                    type Value = Field;
    40
    41                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    42                        f.write_str("field identifier")
    43                    }
    44
    45                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
    46                        Ok(match v {
    47                            "fsType" => Field::Key_fs_type,
    48                            "readOnly" => Field::Key_read_only,
    49                            "volumeID" => Field::Key_volume_id,
    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 = PortworxVolumeSource;
    63
    64            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    65                f.write_str("PortworxVolumeSource")
    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_fs_type: Option<std::string::String> = None;
    70                let mut value_read_only: Option<bool> = None;
    71                let mut value_volume_id: Option<std::string::String> = None;
    72
    73                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
    74                    match key {
    75                        Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
    76                        Field::Key_read_only => value_read_only = crate::serde::de::MapAccess::next_value(&mut map)?,
    77                        Field::Key_volume_id => value_volume_id = crate::serde::de::MapAccess::next_value(&mut map)?,
    78                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
    79                    }
    80                }
    81
    82                Ok(PortworxVolumeSource {
    83                    fs_type: value_fs_type,
    84                    read_only: value_read_only,
    85                    volume_id: value_volume_id.unwrap_or_default(),
    86                })
    87            }
    88        }
    89
    90        deserializer.deserialize_struct(
    91            "PortworxVolumeSource",
    92            &[
    93                "fsType",
    94                "readOnly",
    95                "volumeID",
    96            ],
    97            Visitor,
    98        )
    99    }
    100}
    101
    102impl crate::serde::Serialize for PortworxVolumeSource {
    103    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
    104        let mut state = serializer.serialize_struct(
    105            "PortworxVolumeSource",
    106            1 +
    107            self.fs_type.as_ref().map_or(0, |_| 1) +
    108            self.read_only.as_ref().map_or(0, |_| 1),
    109        )?;
    110        if let Some(value) = &self.fs_type {
    111            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
    112        }
    113        if let Some(value) = &self.read_only {
    114            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "readOnly", value)?;
    115        }
    116        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "volumeID", &self.volume_id)?;
    117        crate::serde::ser::SerializeStruct::end(state)
    118    }
    119}
    120
    121#[cfg(feature = "schemars")]
    122impl crate::schemars::JsonSchema for PortworxVolumeSource {
    123    fn schema_name() -> std::borrow::Cow<'static, str> {
    124        "io.k8s.api.core.v1.PortworxVolumeSource".into()
    125    }
    126
    127    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    128        crate::schemars::json_schema!({
    129            "description": "PortworxVolumeSource represents a Portworx volume resource.",
    130            "type": "object",
    131            "properties": {
    132                "fsType": {
    133                    "description": "fSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\". Implicitly inferred to be \"ext4\" if unspecified.",
    134                    "type": "string",
    135                },
    136                "readOnly": {
    137                    "description": "readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
    138                    "type": "boolean",
    139                },
    140                "volumeID": {
    141                    "description": "volumeID uniquely identifies a Portworx volume",
    142                    "type": "string",
    143                },
    144            },
    145            "required": [
    146                "volumeID",
    147            ],
    148        })
    149    }
    150}