Skip to main content

asterust_junos/system/
dynamic_profile_options.rs

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