use crate::{VlanConfig, VlanInterface};
impl VlanInterface {
pub(crate) fn update_vlan(&mut self, other: &VlanInterface) {
if let Some(vlan_conf) = &mut self.vlan {
vlan_conf.update(other.vlan.as_ref());
} else {
self.vlan.clone_from(&other.vlan);
}
}
pub(crate) fn include_diff_context(
&mut self,
desired: &VlanInterface,
current: &VlanInterface,
) {
if let (Some(des_conf), Some(cur_conf)) =
(desired.vlan.as_ref(), current.vlan.as_ref())
{
if des_conf != cur_conf {
let new_conf = VlanConfig {
id: des_conf.id,
base_iface: des_conf
.base_iface
.clone()
.or_else(|| cur_conf.base_iface.clone()),
..Default::default()
};
self.vlan = Some(new_conf);
}
}
}
}
impl VlanConfig {
fn update(&mut self, other: Option<&Self>) {
if let Some(other) = other {
self.base_iface.clone_from(&other.base_iface);
self.id = other.id;
self.protocol = other.protocol;
}
}
}