asterust_junos/policy_options/as_path.rs
1//! `as-path`
2//! `policy-options { as-path <name> <regular-expression>; }`.
3//!
4//! # See also
5//!
6//! - [as-path (Policy Options)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/as-path-edit-policy-options.html)
7
8use crate::{split_name, unquote};
9use asterust::config::ConfigLine;
10
11/// An `as-path <name> <regular-expression>`.
12#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct AsPath {
15 pub name: String,
16 pub regex: String,
17}
18
19pub(super) fn parse_as_path(line: &ConfigLine) -> Option<AsPath> {
20 let (name, regex) = split_name(line.arg("as-path")?);
21 Some(AsPath {
22 name: name.to_string(),
23 regex: unquote(regex).to_string(),
24 })
25}