Skip to main content

asterust_junos/interfaces/otn_options/
rate.rs

1//! `rate`
2//! `interfaces { <name> { otn-options { rate { ... } } } }`.
3//!
4//! # See also
5//!
6//! - [rate](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/rate-edit-interfaces-otn-options.html)
7
8use crate::{has_leaf, toggle};
9use asterust::config::ConfigLine;
10
11/// The `rate` of an OTN interface.
12#[derive(Clone, Debug, Default, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct OtnRate {
15    /// `Some(true)` for `fixed-stuff-bytes`, `Some(false)` for `no-fixed-stuff-bytes`.
16    pub fixed_stuff_bytes: Option<bool>,
17    /// `Some(true)` for `pass-through`, `Some(false)` for `no-pass-through`.
18    pub pass_through: Option<bool>,
19    pub otu4: bool,
20    pub oc192: bool,
21}
22
23pub(super) fn parse_rate(rate: &ConfigLine) -> OtnRate {
24    OtnRate {
25        fixed_stuff_bytes: toggle(rate, "fixed-stuff-bytes"),
26        pass_through: toggle(rate, "pass-through"),
27        otu4: has_leaf(rate, "otu4"),
28        oc192: has_leaf(rate, "oc192"),
29    }
30}