Skip to main content

asterust_junos/system/
dynamic_profile_options.rs

1//! `system { dynamic-profile-options { ... } }`.
2
3use crate::has_leaf;
4use asterust::config::ConfigLine;
5
6/// The `system dynamic-profile-options` settings.
7#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct DynamicProfileOptions {
10    pub versioning: bool,
11}
12
13pub(super) fn parse_dynamic_profile_options(options: &ConfigLine) -> DynamicProfileOptions {
14    DynamicProfileOptions {
15        versioning: has_leaf(options, "versioning"),
16    }
17}
18
19#[cfg(test)]
20mod tests {
21    use crate::system::system;
22    use asterust::config::juniper;
23
24    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
25    #[test]
26    fn extracts_dynamic_profile_options() {
27        let system = system(&juniper::parse_braces(
28            "system {\n    dynamic-profile-options {\n        versioning;\n    }\n}\n",
29        ))
30        .unwrap();
31        assert!(system.dynamic_profile_options.unwrap().versioning);
32    }
33}