#[derive(
    Clone,
    Default,
    PartialEq,
    serde::Deserialize,
    serde::Serialize,
    std::fmt::Debug
)]
/// Maps a string key to a path within a volume.
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct KeyToPathAc {
    /// key is the key to project.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub key: Option<std::string::String>,
    /// mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mode: Option<i32>,
    /// path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<std::string::String>,
}
#[automatically_derived]
impl crate::Optionable for k8s_openapi027::api::core::v1::KeyToPath {
    type Optioned = KeyToPathAc;
}
#[automatically_derived]
impl crate::Optionable for KeyToPathAc {
    type Optioned = KeyToPathAc;
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionableConvert for k8s_openapi027::api::core::v1::KeyToPath {
    fn into_optioned(self) -> KeyToPathAc {
        KeyToPathAc {
            key: Some(self.key),
            mode: self.mode,
            path: Some(self.path),
        }
    }
    fn try_from_optioned(value: KeyToPathAc) -> Result<Self, crate::Error> {
        Ok(Self {
            key: value
                .key
                .ok_or(crate::Error {
                    missing_field: "key",
                })?,
            mode: value.mode,
            path: value
                .path
                .ok_or(crate::Error {
                    missing_field: "path",
                })?,
        })
    }
    fn merge(&mut self, other: KeyToPathAc) -> Result<(), crate::Error> {
        if let Some(other_value) = other.key {
            self.key = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        if self.mode.is_none() {
            self.mode = crate::OptionableConvert::try_from_optioned(other.mode)?;
        } else if let Some(self_value) = self.mode.as_mut()
            && let Some(other_value) = other.mode
        {
            crate::OptionableConvert::merge(self_value, other_value)?;
        }
        if let Some(other_value) = other.path {
            self.path = crate::OptionableConvert::try_from_optioned(other_value)?;
        }
        Ok(())
    }
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionedConvert<k8s_openapi027::api::core::v1::KeyToPath> for KeyToPathAc {
    fn from_optionable(value: k8s_openapi027::api::core::v1::KeyToPath) -> Self {
        crate::OptionableConvert::into_optioned(value)
    }
    fn try_into_optionable(
        self,
    ) -> Result<k8s_openapi027::api::core::v1::KeyToPath, crate::Error> {
        crate::OptionableConvert::try_from_optioned(self)
    }
    fn merge_into(
        self,
        other: &mut k8s_openapi027::api::core::v1::KeyToPath,
    ) -> Result<(), crate::Error> {
        crate::OptionableConvert::merge(other, self)
    }
}
impl k8s_openapi027::DeepMerge for KeyToPathAc {
    fn merge_from(&mut self, other: Self) {
        k8s_openapi027::DeepMerge::merge_from(&mut self.key, other.key);
        k8s_openapi027::DeepMerge::merge_from(&mut self.mode, other.mode);
        k8s_openapi027::DeepMerge::merge_from(&mut self.path, other.path);
    }
}
