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

    1// Generated from definition io.k8s.api.core.v1.ContainerExtendedResourceRequest
    2
    3/// ContainerExtendedResourceRequest has the mapping of container name, extended resource name to the device request name.
    4#[derive(Clone, Debug, Default, PartialEq)]
    5pub struct ContainerExtendedResourceRequest {
    6    /// The name of the container requesting resources.
    7    pub container_name: std::string::String,
    8
    9    /// The name of the request in the special ResourceClaim which corresponds to the extended resource.
    10    pub request_name: std::string::String,
    11
    12    /// The name of the extended resource in that container which gets backed by DRA.
    13    pub resource_name: std::string::String,
    14}
    15
    16impl crate::DeepMerge for ContainerExtendedResourceRequest {
    17    fn merge_from(&mut self, other: Self) {
    18        crate::DeepMerge::merge_from(&mut self.container_name, other.container_name);
    19        crate::DeepMerge::merge_from(&mut self.request_name, other.request_name);
    20        crate::DeepMerge::merge_from(&mut self.resource_name, other.resource_name);
    21    }
    22}
    23
    24impl<'de> crate::serde::Deserialize<'de> for ContainerExtendedResourceRequest {
    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_container_name,
    29            Key_request_name,
    30            Key_resource_name,
    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                            "containerName" => Field::Key_container_name,
    48                            "requestName" => Field::Key_request_name,
    49                            "resourceName" => Field::Key_resource_name,
    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 = ContainerExtendedResourceRequest;
    63
    64            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    65                f.write_str("ContainerExtendedResourceRequest")
    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_container_name: Option<std::string::String> = None;
    70                let mut value_request_name: Option<std::string::String> = None;
    71                let mut value_resource_name: 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_container_name => value_container_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    76                        Field::Key_request_name => value_request_name = crate::serde::de::MapAccess::next_value(&mut map)?,
    77                        Field::Key_resource_name => value_resource_name = 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(ContainerExtendedResourceRequest {
    83                    container_name: value_container_name.unwrap_or_default(),
    84                    request_name: value_request_name.unwrap_or_default(),
    85                    resource_name: value_resource_name.unwrap_or_default(),
    86                })
    87            }
    88        }
    89
    90        deserializer.deserialize_struct(
    91            "ContainerExtendedResourceRequest",
    92            &[
    93                "containerName",
    94                "requestName",
    95                "resourceName",
    96            ],
    97            Visitor,
    98        )
    99    }
    100}
    101
    102impl crate::serde::Serialize for ContainerExtendedResourceRequest {
    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            "ContainerExtendedResourceRequest",
    106            3,
    107        )?;
    108        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "containerName", &self.container_name)?;
    109        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "requestName", &self.request_name)?;
    110        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "resourceName", &self.resource_name)?;
    111        crate::serde::ser::SerializeStruct::end(state)
    112    }
    113}
    114
    115#[cfg(feature = "schemars")]
    116impl crate::schemars::JsonSchema for ContainerExtendedResourceRequest {
    117    fn schema_name() -> std::borrow::Cow<'static, str> {
    118        "io.k8s.api.core.v1.ContainerExtendedResourceRequest".into()
    119    }
    120
    121    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
    122        crate::schemars::json_schema!({
    123            "description": "ContainerExtendedResourceRequest has the mapping of container name, extended resource name to the device request name.",
    124            "type": "object",
    125            "properties": {
    126                "containerName": {
    127                    "description": "The name of the container requesting resources.",
    128                    "type": "string",
    129                },
    130                "requestName": {
    131                    "description": "The name of the request in the special ResourceClaim which corresponds to the extended resource.",
    132                    "type": "string",
    133                },
    134                "resourceName": {
    135                    "description": "The name of the extended resource in that container which gets backed by DRA.",
    136                    "type": "string",
    137                },
    138            },
    139            "required": [
    140                "containerName",
    141                "requestName",
    142                "resourceName",
    143            ],
    144        })
    145    }
    146}