use crate::{split_name, value_after};
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct QualifiedNextHop {
pub next_hop: String,
pub interface: Option<String>,
pub mac_address: Option<String>,
pub preference: Option<String>,
pub metric: Option<String>,
pub tag: Option<String>,
pub order: Option<String>,
}
pub(super) fn parse_qualified_next_hop(arg: &str, children: &[&ConfigLine]) -> QualifiedNextHop {
let (next_hop, inline) = split_name(arg);
let words: Vec<&str> = inline
.split_whitespace()
.chain(children.iter().flat_map(|child| child.text.split_whitespace()))
.collect();
QualifiedNextHop {
next_hop: next_hop.to_string(),
interface: value_after(&words, "interface"),
mac_address: value_after(&words, "mac-address"),
preference: value_after(&words, "preference"),
metric: value_after(&words, "metric"),
tag: value_after(&words, "tag"),
order: value_after(&words, "order"),
}
}