#[derive(
Clone,
Default,
PartialEq,
serde::Deserialize,
serde::Serialize,
std::fmt::Debug
)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct DeviceAc {
#[serde(skip_serializing_if = "Option::is_none")]
pub all_nodes: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_multiple_allocations: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<
std::collections::BTreeMap<
std::string::String,
<::k8s_openapi027::api::resource::v1beta2::DeviceAttribute as crate::Optionable>::Optioned,
>,
>,
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_conditions: Option<std::vec::Vec<std::string::String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub binding_failure_conditions: Option<std::vec::Vec<std::string::String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub binds_to_node: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub capacity: Option<
std::collections::BTreeMap<
std::string::String,
<::k8s_openapi027::api::resource::v1beta2::DeviceCapacity as crate::Optionable>::Optioned,
>,
>,
#[serde(skip_serializing_if = "Option::is_none")]
pub consumes_counters: Option<
std::vec::Vec<
<::k8s_openapi027::api::resource::v1beta2::DeviceCounterConsumption as crate::Optionable>::Optioned,
>,
>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<std::string::String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_name: Option<std::string::String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_selector: Option<
<::k8s_openapi027::api::core::v1::NodeSelector as crate::Optionable>::Optioned,
>,
#[serde(skip_serializing_if = "Option::is_none")]
pub taints: Option<
std::vec::Vec<
<::k8s_openapi027::api::resource::v1beta2::DeviceTaint as crate::Optionable>::Optioned,
>,
>,
}
#[automatically_derived]
impl crate::Optionable for k8s_openapi027::api::resource::v1beta2::Device {
type Optioned = DeviceAc;
}
#[automatically_derived]
impl crate::Optionable for DeviceAc {
type Optioned = DeviceAc;
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionableConvert for k8s_openapi027::api::resource::v1beta2::Device {
fn into_optioned(self) -> DeviceAc {
DeviceAc {
all_nodes: self.all_nodes,
allow_multiple_allocations: self.allow_multiple_allocations,
attributes: crate::OptionableConvert::into_optioned(self.attributes),
binding_conditions: self.binding_conditions,
binding_failure_conditions: self.binding_failure_conditions,
binds_to_node: self.binds_to_node,
capacity: crate::OptionableConvert::into_optioned(self.capacity),
consumes_counters: crate::OptionableConvert::into_optioned(
self.consumes_counters,
),
name: Some(self.name),
node_name: self.node_name,
node_selector: crate::OptionableConvert::into_optioned(self.node_selector),
taints: crate::OptionableConvert::into_optioned(self.taints),
}
}
fn try_from_optioned(value: DeviceAc) -> Result<Self, crate::Error> {
Ok(Self {
all_nodes: value.all_nodes,
allow_multiple_allocations: value.allow_multiple_allocations,
attributes: crate::OptionableConvert::try_from_optioned(value.attributes)?,
binding_conditions: value.binding_conditions,
binding_failure_conditions: value.binding_failure_conditions,
binds_to_node: value.binds_to_node,
capacity: crate::OptionableConvert::try_from_optioned(value.capacity)?,
consumes_counters: crate::OptionableConvert::try_from_optioned(
value.consumes_counters,
)?,
name: value
.name
.ok_or(crate::Error {
missing_field: "name",
})?,
node_name: value.node_name,
node_selector: crate::OptionableConvert::try_from_optioned(
value.node_selector,
)?,
taints: crate::OptionableConvert::try_from_optioned(value.taints)?,
})
}
fn merge(&mut self, other: DeviceAc) -> Result<(), crate::Error> {
if self.all_nodes.is_none() {
self.all_nodes = crate::OptionableConvert::try_from_optioned(
other.all_nodes,
)?;
} else if let Some(self_value) = self.all_nodes.as_mut()
&& let Some(other_value) = other.all_nodes
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.allow_multiple_allocations.is_none() {
self.allow_multiple_allocations = crate::OptionableConvert::try_from_optioned(
other.allow_multiple_allocations,
)?;
} else if let Some(self_value) = self.allow_multiple_allocations.as_mut()
&& let Some(other_value) = other.allow_multiple_allocations
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.attributes.is_none() {
self.attributes = crate::OptionableConvert::try_from_optioned(
other.attributes,
)?;
} else if let Some(self_value) = self.attributes.as_mut()
&& let Some(other_value) = other.attributes
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.binding_conditions.is_none() {
self.binding_conditions = crate::OptionableConvert::try_from_optioned(
other.binding_conditions,
)?;
} else if let Some(self_value) = self.binding_conditions.as_mut()
&& let Some(other_value) = other.binding_conditions
{
*self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
}
if self.binding_failure_conditions.is_none() {
self.binding_failure_conditions = crate::OptionableConvert::try_from_optioned(
other.binding_failure_conditions,
)?;
} else if let Some(self_value) = self.binding_failure_conditions.as_mut()
&& let Some(other_value) = other.binding_failure_conditions
{
*self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
}
if self.binds_to_node.is_none() {
self.binds_to_node = crate::OptionableConvert::try_from_optioned(
other.binds_to_node,
)?;
} else if let Some(self_value) = self.binds_to_node.as_mut()
&& let Some(other_value) = other.binds_to_node
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.capacity.is_none() {
self.capacity = crate::OptionableConvert::try_from_optioned(other.capacity)?;
} else if let Some(self_value) = self.capacity.as_mut()
&& let Some(other_value) = other.capacity
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.consumes_counters.is_none() {
self.consumes_counters = crate::OptionableConvert::try_from_optioned(
other.consumes_counters,
)?;
} else if let Some(self_value) = self.consumes_counters.as_mut()
&& let Some(other_value) = other.consumes_counters
{
*self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
}
if let Some(other_value) = other.name {
self.name = crate::OptionableConvert::try_from_optioned(other_value)?;
}
if self.node_name.is_none() {
self.node_name = crate::OptionableConvert::try_from_optioned(
other.node_name,
)?;
} else if let Some(self_value) = self.node_name.as_mut()
&& let Some(other_value) = other.node_name
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.node_selector.is_none() {
self.node_selector = crate::OptionableConvert::try_from_optioned(
other.node_selector,
)?;
} else if let Some(self_value) = self.node_selector.as_mut()
&& let Some(other_value) = other.node_selector
{
crate::OptionableConvert::merge(self_value, other_value)?;
}
if self.taints.is_none() {
self.taints = crate::OptionableConvert::try_from_optioned(other.taints)?;
} else if let Some(self_value) = self.taints.as_mut()
&& let Some(other_value) = other.taints
{
*self_value = crate::OptionableConvert::try_from_optioned(other_value)?;
}
Ok(())
}
}
#[automatically_derived]
#[cfg(feature = "k8s_openapi_convert")]
impl crate::OptionedConvert<k8s_openapi027::api::resource::v1beta2::Device>
for DeviceAc {
fn from_optionable(value: k8s_openapi027::api::resource::v1beta2::Device) -> Self {
crate::OptionableConvert::into_optioned(value)
}
fn try_into_optionable(
self,
) -> Result<k8s_openapi027::api::resource::v1beta2::Device, crate::Error> {
crate::OptionableConvert::try_from_optioned(self)
}
fn merge_into(
self,
other: &mut k8s_openapi027::api::resource::v1beta2::Device,
) -> Result<(), crate::Error> {
crate::OptionableConvert::merge(other, self)
}
}