Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/models/bgp/attributes/aspath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@ impl AsPath {
_ => None,
}
}

pub fn to_u32_vec(&self) -> Option<Vec<u32>> {
match self.segments.last() {
Some(AsPathSegment::AsSequence(v)) => Some(v.iter().map(|asn| (*asn).into()).collect()),
_ => None,
}
}
}

/// Iterates over all route variations the given `AsPath` represents.
Expand Down
7 changes: 7 additions & 0 deletions src/models/network/asn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ impl From<Asn> for u32 {
}
}

impl From<&Asn> for u32 {
#[inline]
fn from(value: &Asn) -> Self {
value.asn
}
}

impl Display for Asn {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.asn)
Expand Down