asterust-junos 0.3.3

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> { unit <n> { family <name> { rpf-check { ... } } } } }`.

use crate::{statement_words, value_after};
use asterust::config::ConfigLine;

/// The `rpf-check` unicast reverse-path-forwarding settings; both fields are `None` for a bare `rpf-check;`.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct RpfCheck {
    pub fail_filter: Option<String>,
    /// `strict` or `loose`.
    pub mode: Option<String>,
}

pub(super) fn parse_rpf_check(family: &ConfigLine) -> Option<RpfCheck> {
    let words = statement_words(family, "rpf-check")?;
    Some(RpfCheck {
        fail_filter: value_after(&words, "fail-filter"),
        mode: value_after(&words, "mode"),
    })
}