asterust_junos/policy_options/
community.rs1use crate::{active_children, list_values, split_keyword, split_name};
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct Community {
15 pub name: String,
16 pub members: Vec<String>,
17 pub invert_match: bool,
18}
19
20pub(super) fn parse_community(line: &ConfigLine) -> Option<Community> {
22 let (name, rest) = split_name(line.arg("community")?);
23 let (keyword, members) = split_keyword(rest);
24 let mut community = Community {
25 name: name.to_string(),
26 members: if keyword == "members" {
27 list_values(members)
28 } else {
29 Vec::new()
30 },
31 invert_match: false,
32 };
33 for child in active_children(line) {
34 if let Some(members) = child.arg("members") {
35 community.members.extend(list_values(members));
36 } else if child.text == "invert-match" {
37 community.invert_match = true;
38 }
39 }
40 Some(community)
41}