asterust_junos/interfaces/auto_configure/
ranges.rs1use crate::{arg_of, args_of, child_block, named_children};
11use asterust::config::ConfigLine;
12
13#[derive(Clone, Debug, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct AutoConfigureProfile {
17 pub name: String,
18 pub accept: Vec<String>,
20 pub access_profile: Option<String>,
21 pub ranges: Option<String>,
23}
24
25#[derive(Clone, Debug, PartialEq, Eq)]
27#[non_exhaustive]
28pub struct AutoConfigureRanges {
29 pub access_profile: Option<String>,
30 pub dynamic_profiles: Vec<AutoConfigureProfile>,
31 pub has_authentication: bool,
33}
34
35pub(super) fn parse_ranges(ranges: &ConfigLine) -> AutoConfigureRanges {
36 AutoConfigureRanges {
37 access_profile: arg_of(ranges, "access-profile").map(str::to_string),
38 dynamic_profiles: named_children(ranges, "dynamic-profile")
39 .map(|(name, profile)| AutoConfigureProfile {
40 name: name.to_string(),
41 accept: args_of(profile, "accept").into_iter().map(str::to_string).collect(),
42 access_profile: arg_of(profile, "access-profile").map(str::to_string),
43 ranges: arg_of(profile, "ranges").map(str::to_string),
44 })
45 .collect(),
46 has_authentication: child_block(ranges, "authentication").is_some(),
47 }
48}