Skip to main content

asterust_junos/protocols/mpls/
interface.rs

1//! `interface`
2//! `protocols { mpls { interface (<name> | all) { ... } } }`.
3//!
4//! # See also
5//!
6//! - [interface (Protocols MPLS)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/interface-edit-protocols-mpls.html)
7
8use crate::{args_of, has_leaf, list_values};
9use asterust::config::ConfigLine;
10
11/// An `interface <name>` entry of MPLS; the name can be `all`.
12#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct MplsInterface {
15    pub name: String,
16    pub disable: bool,
17    /// The `admin-group` names applied to the link.
18    pub admin_groups: Vec<String>,
19    pub srlg: Vec<String>,
20}
21
22pub(super) fn parse_interface(name: &str, interface: &ConfigLine) -> MplsInterface {
23    let list =
24        |keyword: &str| -> Vec<String> { args_of(interface, keyword).into_iter().flat_map(list_values).collect() };
25    MplsInterface {
26        name: name.to_string(),
27        disable: has_leaf(interface, "disable"),
28        admin_groups: list("admin-group"),
29        srlg: list("srlg"),
30    }
31}