Skip to main content

asterust_junos/system/
demux_options.rs

1//! `demux-options`
2//! `system { demux-options { ... } }`.
3//!
4//! # See also
5//!
6//! - [demux-options (All Demux Interfaces)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/demux-options-edit-system.html)
7//! - [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)
8
9use crate::has_leaf;
10use asterust::config::ConfigLine;
11
12/// The `system demux-options` settings.
13#[derive(Clone, Debug, PartialEq, Eq)]
14#[non_exhaustive]
15pub struct DemuxOptions {
16    /// Use the same link-local address on a dynamic demux interface and its underlying static one.
17    pub use_underlying_interface_mac: bool,
18}
19
20pub(super) fn parse_demux_options(demux: &ConfigLine) -> DemuxOptions {
21    DemuxOptions {
22        use_underlying_interface_mac: has_leaf(demux, "use-underlying-interface-mac"),
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use crate::system::system;
29    use asterust::config::juniper;
30
31    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
32    #[test]
33    fn extracts_demux_options() {
34        let demux = system(&juniper::parse_braces(
35            "system {\n    demux-options {\n        use-underlying-interface-mac;\n    }\n}\n",
36        ))
37        .unwrap()
38        .demux_options
39        .unwrap();
40        assert!(demux.use_underlying_interface_mac);
41    }
42
43    #[test]
44    fn no_demux_options_is_none() {
45        let system = system(&juniper::parse_braces("system {\n    host-name pe1;\n}\n")).unwrap();
46        assert!(system.demux_options.is_none());
47    }
48}