asterust-junos 0.3.16

Typed Juniper JunOS config views (interfaces, OSPF, BGP, IS-IS, routing instances, policy options, firewall filters, system) extracted from an asterust config tree.
Documentation
//! `realm`
//! `protocols { ospf3 { realm (ipv4-unicast | ipv4-multicast | ipv6-multicast) { area <id> { ... } } } }`.
//!
//! # See also
//!
//! - [realm](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/realm-edit-protocols-ospf3.html)

use super::area::{parse_area, OspfArea};
use crate::named_children;
use asterust::config::ConfigLine;

/// A `realm` of OSPFv3, which advertises an address family other than unicast IPv6 with its own neighbors and
/// link-state database.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct OspfRealm {
    /// `ipv4-unicast`, `ipv4-multicast` or `ipv6-multicast`.
    pub name: String,
    pub areas: Vec<OspfArea>,
}

pub(super) fn parse_realms(ospf: &ConfigLine) -> Vec<OspfRealm> {
    named_children(ospf, "realm")
        .map(|(name, realm)| OspfRealm {
            name: name.to_string(),
            areas: named_children(realm, "area")
                .map(|(id, area)| parse_area(id, area))
                .collect(),
        })
        .collect()
}