asterust-junos 0.5.12

Typed Juniper JunOS config views (interfaces, protocols, routing instances and options, policy options, firewall filters, class of service, system, services) extracted from an asterust config tree.
Documentation
//! `redundant-ether-options`
//! `interfaces { reth<n> { redundant-ether-options { ... } } }`.
//!
//! # See also
//!
//! - [redundant-ether-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/interfaces-edit-redundant-ether-options.html)

use super::aggregated_ether_options::{parse_lacp, Lacp};
use super::ether_options::source_address_filter;
use crate::{arg_of, child_block, toggle};
use asterust::config::ConfigLine;

/// The `redundant-ether-options` of a redundant Ethernet interface.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct RedundantEtherOptions {
    /// `Some(true)` for `flow-control`, `Some(false)` for `no-flow-control`.
    pub flow_control: Option<bool>,
    pub lacp: Option<Lacp>,
    pub link_speed: Option<String>,
    /// `Some(true)` for `loopback`, `Some(false)` for `no-loopback`.
    pub loopback: Option<bool>,
    pub minimum_links: Option<String>,
    pub redundancy_group: Option<String>,
    /// The MAC addresses of `source-address-filter`.
    pub source_address_filter: Vec<String>,
    /// `Some(true)` for `source-filtering`, `Some(false)` for `no-source-filtering`.
    pub source_filtering: Option<bool>,
}

pub(super) fn parse_redundant_ether_options(options: &ConfigLine) -> RedundantEtherOptions {
    RedundantEtherOptions {
        flow_control: toggle(options, "flow-control"),
        lacp: child_block(options, "lacp").map(parse_lacp),
        link_speed: arg_of(options, "link-speed").map(str::to_string),
        loopback: toggle(options, "loopback"),
        minimum_links: arg_of(options, "minimum-links").map(str::to_string),
        redundancy_group: arg_of(options, "redundancy-group").map(str::to_string),
        source_address_filter: source_address_filter(options),
        source_filtering: toggle(options, "source-filtering"),
    }
}