asterust_junos/policy_options/
prefix_list.rs1use crate::{active_children, has_leaf, 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 pub dynamic_db: bool,
20}
21
22pub(super) fn parse_prefix_list(name: &str, line: &ConfigLine) -> PrefixList {
23 let mut list = PrefixList {
24 name: name.to_string(),
25 prefixes: Vec::new(),
26 apply_path: None,
27 dynamic_db: has_leaf(line, "dynamic-db"),
28 };
29 for child in active_children(line) {
30 if let Some(path) = child.arg("apply-path") {
31 list.apply_path = Some(unquote(path).to_string());
32 } else if !child.text.contains(' ') {
33 list.prefixes.push(child.text.clone());
35 }
36 }
37 list
38}