asterust-junos 0.3.6

Typed Juniper JunOS config views (interfaces, OSPF, BGP, IS-IS, routing instances, policy options, firewall filters, system) extracted from an asterust config tree.
Documentation
//! `interfaces { <name> { otn-options { signal-degrade { ... } } } }`.

use crate::arg_of;
use asterust::config::ConfigLine;

/// The BER thresholds of `signal-degrade`, e.g. `"7.5E-3"`.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct SignalDegrade {
    pub ber_threshold_signal_degrade: Option<String>,
    pub ber_threshold_clear: Option<String>,
    /// Milliseconds.
    pub interval: Option<String>,
}

pub(super) fn parse_signal_degrade(signal_degrade: &ConfigLine) -> SignalDegrade {
    let field = |keyword: &str| arg_of(signal_degrade, keyword).map(str::to_string);
    SignalDegrade {
        ber_threshold_signal_degrade: field("ber-threshold-signal-degrade"),
        ber_threshold_clear: field("ber-threshold-clear"),
        interval: field("interval"),
    }
}