Skip to main content

asterust_junos/interfaces/
aggregated_inline_services_options.rs

1//! `aggregated-inline-services-options`
2//! `interfaces { asi<n> { aggregated-inline-services-options { ... } } }`.
3//!
4//! # See also
5//!
6//! - [aggregated-inline-services-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/aggregated-inlinesvcs-options-edit-interfaces.html)
7
8use crate::arg_of;
9use asterust::config::ConfigLine;
10
11/// The `aggregated-inline-services-options` of an `asi` interface.
12#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct AggregatedInlineServicesOptions {
15    pub primary_interface: Option<String>,
16    pub secondary_interface: Option<String>,
17}
18
19pub(super) fn parse_aggregated_inline_services_options(options: &ConfigLine) -> AggregatedInlineServicesOptions {
20    AggregatedInlineServicesOptions {
21        primary_interface: arg_of(options, "primary-interface").map(str::to_string),
22        secondary_interface: arg_of(options, "secondary-interface").map(str::to_string),
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use crate::interfaces::interfaces;
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_aggregated_inline_services_options() {
34        let ifaces = interfaces(&juniper::parse_braces(
35            "interfaces {\n    asi0 {\n        aggregated-inline-services-options {\n            primary-interface si-1/0/0;\n            secondary-interface si-2/0/0;\n        }\n    }\n}\n",
36        ));
37        let options = ifaces[0].aggregated_inline_services_options.as_ref().unwrap();
38        assert_eq!(options.primary_interface.as_deref(), Some("si-1/0/0"));
39        assert_eq!(options.secondary_interface.as_deref(), Some("si-2/0/0"));
40    }
41}