use crate::arg_of;
use asterust::config::ConfigLine;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct AggregatedInlineServicesOptions {
pub primary_interface: Option<String>,
pub secondary_interface: Option<String>,
}
pub(super) fn parse_aggregated_inline_services_options(options: &ConfigLine) -> AggregatedInlineServicesOptions {
AggregatedInlineServicesOptions {
primary_interface: arg_of(options, "primary-interface").map(str::to_string),
secondary_interface: arg_of(options, "secondary-interface").map(str::to_string),
}
}
#[cfg(test)]
mod tests {
use crate::interfaces::interfaces;
use asterust::config::juniper;
#[test]
fn extracts_aggregated_inline_services_options() {
let ifaces = interfaces(&juniper::parse_braces(
"interfaces {\n asi0 {\n aggregated-inline-services-options {\n primary-interface si-1/0/0;\n secondary-interface si-2/0/0;\n }\n }\n}\n",
));
let options = ifaces[0].aggregated_inline_services_options.as_ref().unwrap();
assert_eq!(options.primary_interface.as_deref(), Some("si-1/0/0"));
assert_eq!(options.secondary_interface.as_deref(), Some("si-2/0/0"));
}
}