asterust_junos/policy_options/
prefix_list.rs1use crate::{active_children, unquote};
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct PrefixList {
15 pub name: String,
16 pub prefixes: Vec<String>,
17 pub apply_path: Option<String>,
18}
19
20pub(super) fn parse_prefix_list(name: &str, line: &ConfigLine) -> PrefixList {
21 let mut list = PrefixList {
22 name: name.to_string(),
23 prefixes: Vec::new(),
24 apply_path: None,
25 };
26 for child in active_children(line) {
27 if let Some(path) = child.arg("apply-path") {
28 list.apply_path = Some(unquote(path).to_string());
29 } else if !child.text.contains(' ') {
30 list.prefixes.push(child.text.clone());
32 }
33 }
34 list
35}