Skip to main content

asterust_junos/interfaces/
layer2_policer.rs

1//! `layer2-policer`
2//! `interfaces { <name> { layer2-policer { ... } } }`.
3//!
4//! # See also
5//!
6//! - [layer2-policer (EX)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/layer2-policer-edit-interfaces-ni.html)
7//! - [layer2-policer (Hierarchical Policer)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/layer2-policer-edit-interfaces-ge-or-xe.html)
8
9use crate::arg_of;
10use asterust::config::ConfigLine;
11
12/// The policers applied to an interface by `layer2-policer`.
13#[derive(Clone, Debug, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct Layer2Policer {
16    pub input_policer: Option<String>,
17    pub input_three_color: Option<String>,
18    pub output_policer: Option<String>,
19    pub output_three_color: Option<String>,
20    pub input_hierarchical_policer: Option<String>,
21}
22
23pub(super) fn parse_layer2_policer(policer: &ConfigLine) -> Layer2Policer {
24    let value = |keyword| arg_of(policer, keyword).map(str::to_string);
25    Layer2Policer {
26        input_policer: value("input-policer"),
27        input_three_color: value("input-three-color"),
28        output_policer: value("output-policer"),
29        output_three_color: value("output-three-color"),
30        input_hierarchical_policer: value("input-hierarchical-policer"),
31    }
32}