Skip to main content

asterust_junos/policy_options/
as_path_group.rs

1//! `as-path-group`
2//! `policy-options { as-path-group <name> { ... } }`.
3//!
4//! # See also
5//!
6//! - [as-path-group](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/as-path-group-edit-policy-options.html)
7
8use super::as_path::{parse_as_path, AsPath};
9use crate::active_children;
10use asterust::config::ConfigLine;
11
12/// An `as-path-group <name>` of AS path expressions.
13#[derive(Clone, Debug, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct AsPathGroup {
16    pub name: String,
17    pub as_paths: Vec<AsPath>,
18}
19
20pub(super) fn parse_as_path_group(name: &str, group: &ConfigLine) -> AsPathGroup {
21    AsPathGroup {
22        name: name.to_string(),
23        as_paths: active_children(group).filter_map(parse_as_path).collect(),
24    }
25}