asterust_junos/policy_options/as_path.rs
1//! `policy-options { as-path <name> <regular-expression>; }`.
2
3use crate::{split_name, unquote};
4use asterust::config::ConfigLine;
5
6/// An `as-path <name> <regular-expression>`.
7#[derive(Clone, Debug, PartialEq, Eq)]
8#[non_exhaustive]
9pub struct AsPath {
10 pub name: String,
11 pub regex: String,
12}
13
14pub(super) fn parse_as_path(line: &ConfigLine) -> Option<AsPath> {
15 let (name, regex) = split_name(line.arg("as-path")?);
16 Some(AsPath {
17 name: name.to_string(),
18 regex: unquote(regex).to_string(),
19 })
20}