pub struct AsPath {
pub segments: Vec<AsPathSegment>,
}Expand description
AS_PATH attribute.
Fields§
§segments: Vec<AsPathSegment>Ordered list of path segments.
Implementations§
Source§impl AsPath
impl AsPath
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Count the total number of ASNs in the path for best-path comparison.
AS_SET counts as 1 regardless of size (RFC 4271 §9.1.2.2).
Sourcepub fn contains_asn(&self, asn: u32) -> bool
pub fn contains_asn(&self, asn: u32) -> bool
Returns true if asn appears in any segment (AS_SEQUENCE or AS_SET).
Used for loop detection per RFC 4271 §9.1.2.
Sourcepub fn origin_asn(&self) -> Option<u32>
pub fn origin_asn(&self) -> Option<u32>
Extract the origin ASN from the AS_PATH.
The origin AS is the last ASN in the rightmost AS_SEQUENCE segment.
Returns None if the path has no AS_SEQUENCE segments or all
AS_SEQUENCE segments are empty.
Sourcepub fn all_private(&self) -> bool
pub fn all_private(&self) -> bool
Returns true if every ASN in the path is a private ASN.
Returns false for empty paths (no ASNs to check).
Sourcepub fn to_aspath_string(&self) -> String
pub fn to_aspath_string(&self) -> String
Convert to a string representation for regex matching.
AS_SEQUENCE segments produce space-separated ASNs.
AS_SET segments produce {ASN1 ASN2} (curly braces, space-separated).
Multiple segments are space-separated.
Examples: "65001 65002", "65001 {65003 65004}", "" (empty path).