asterust_junos/system/services/
static_subscribers.rs1use crate::{arg_of, args_of, named_children};
4use asterust::config::ConfigLine;
5
6#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct StaticSubscriberProfile {
10 pub name: String,
11 pub aggregate_clients: Option<String>,
13}
14
15#[derive(Clone, Debug, PartialEq, Eq)]
17#[non_exhaustive]
18pub struct StaticSubscriberGroup {
19 pub name: String,
20 pub access_profile: Option<String>,
21 pub dynamic_profiles: Vec<StaticSubscriberProfile>,
22 pub interfaces: Vec<String>,
24}
25
26#[derive(Clone, Debug, PartialEq, Eq)]
29#[non_exhaustive]
30pub struct StaticSubscribers {
31 pub access_profile: Option<String>,
32 pub service_profile: Option<String>,
33 pub groups: Vec<StaticSubscriberGroup>,
34}
35
36pub(super) fn parse_static_subscribers(subscribers: &ConfigLine) -> StaticSubscribers {
37 StaticSubscribers {
38 access_profile: arg_of(subscribers, "access-profile").map(str::to_string),
39 service_profile: arg_of(subscribers, "service-profile").map(str::to_string),
40 groups: named_children(subscribers, "group")
41 .map(|(name, group)| StaticSubscriberGroup {
42 name: name.to_string(),
43 access_profile: arg_of(group, "access-profile").map(str::to_string),
44 dynamic_profiles: named_children(group, "dynamic-profile")
45 .map(|(name, profile)| StaticSubscriberProfile {
46 name: name.to_string(),
47 aggregate_clients: arg_of(profile, "aggregate-clients").map(str::to_string),
48 })
49 .collect(),
50 interfaces: args_of(group, "interface").into_iter().map(str::to_string).collect(),
51 })
52 .collect(),
53 }
54}