use crate::{arg_of, child_block, named_children};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct MultiChassisProtection {
pub peer: String,
pub interface: Option<String>,
}
pub(super) fn parse_multi_chassis_protection(interface: &ConfigLine) -> Option<MultiChassisProtection> {
let (peer, block) = named_children(interface, "multi-chassis-protection")
.next()
.or_else(|| {
let protection = child_block(interface, "multi-chassis-protection")?;
named_children(protection, "peer").next()
})?;
Some(MultiChassisProtection {
peer: peer.to_string(),
interface: arg_of(block, "interface").map(str::to_string),
})
}