Skip to main content

asterust_junos/interfaces/otn_options/
rate.rs

1//! `interfaces { <name> { otn-options { rate { ... } } } }`.
2
3use crate::{has_leaf, toggle};
4use asterust::config::ConfigLine;
5
6/// The `rate` of an OTN interface.
7#[derive(Clone, Debug, Default, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct OtnRate {
10    /// `Some(true)` for `fixed-stuff-bytes`, `Some(false)` for `no-fixed-stuff-bytes`.
11    pub fixed_stuff_bytes: Option<bool>,
12    /// `Some(true)` for `pass-through`, `Some(false)` for `no-pass-through`.
13    pub pass_through: Option<bool>,
14    pub otu4: bool,
15    pub oc192: bool,
16}
17
18pub(super) fn parse_rate(rate: &ConfigLine) -> OtnRate {
19    OtnRate {
20        fixed_stuff_bytes: toggle(rate, "fixed-stuff-bytes"),
21        pass_through: toggle(rate, "pass-through"),
22        otu4: has_leaf(rate, "otu4"),
23        oc192: has_leaf(rate, "oc192"),
24    }
25}