asterust-junos 0.5.10

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
//! `demux-options`
//! `system { demux-options { ... } }`.
//!
//! # See also
//!
//! - [demux-options (All Demux Interfaces)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/demux-options-edit-system.html)
//! - [use-underlying-interface-mac](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/use-underlying-interface-mac-edit-system.html)

use crate::has_leaf;
use asterust::config::ConfigLine;

/// The `system demux-options` settings.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct DemuxOptions {
    /// Use the same link-local address on a dynamic demux interface and its underlying static one.
    pub use_underlying_interface_mac: bool,
}

pub(super) fn parse_demux_options(demux: &ConfigLine) -> DemuxOptions {
    DemuxOptions {
        use_underlying_interface_mac: has_leaf(demux, "use-underlying-interface-mac"),
    }
}

#[cfg(test)]
mod tests {
    use crate::system::system;
    use asterust::config::juniper;

    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
    #[test]
    fn extracts_demux_options() {
        let demux = system(&juniper::parse_braces(
            "system {\n    demux-options {\n        use-underlying-interface-mac;\n    }\n}\n",
        ))
        .unwrap()
        .demux_options
        .unwrap();
        assert!(demux.use_underlying_interface_mac);
    }

    #[test]
    fn no_demux_options_is_none() {
        let system = system(&juniper::parse_braces("system {\n    host-name pe1;\n}\n")).unwrap();
        assert!(system.demux_options.is_none());
    }
}