asterust-junos 0.3.13

Typed Juniper JunOS config views (interfaces, OSPF, BGP, IS-IS, routing instances, policy options, firewall filters, system) extracted from an asterust config tree.
Documentation
//! `sglimit` and `register-limit`
//! `protocols { pim { sglimit { ... } rp { register-limit { ... } } } }`.
//!
//! # See also
//!
//! - [sglimit](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/sglimit-edit-protocols-pim.html)
//! - [register-limit](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/register-limit-edit-protocols-pim.html)

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

/// The limits of `sglimit` or `register-limit` written directly under the statement. The per-`family` forms are not
/// extracted.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct PimLimits {
    pub maximum: Option<String>,
    /// Percentage of `maximum` at which a warning is logged.
    pub threshold: Option<String>,
    /// Seconds between log messages.
    pub log_interval: Option<String>,
}

pub(super) fn parse_limits(limits: &ConfigLine) -> PimLimits {
    PimLimits {
        maximum: arg_of(limits, "maximum").map(str::to_string),
        threshold: arg_of(limits, "threshold").map(str::to_string),
        log_interval: arg_of(limits, "log-interval").map(str::to_string),
    }
}