pub struct AsPathView<'a> { /* private fields */ }Expand description
Zero-allocation borrowed view over an element’s effective AS_PATH.
Iterating an AsPathView yields every Asn across its wire segments in order, expanding
AS_SET (and confederation) segments inline on the fly without allocating. Call
segments to inspect segment boundaries or to_vec to
materialise an owned Vec<Asn>.
Implementations§
Source§impl<'a> AsPathView<'a>
impl<'a> AsPathView<'a>
Sourcepub fn is_present(&self) -> bool
pub fn is_present(&self) -> bool
Returns true if a valid AS_PATH (or AS4_PATH) attribute is present on the element
(including an empty 0-segment iBGP AS_PATH).
Sourcepub fn has_no_asns(&self) -> bool
pub fn has_no_asns(&self) -> bool
Returns true if the path yields no AS numbers.
Not the same question as AsPath::is_empty, which asks whether the path has no segments:
a path made of one empty segment has a segment and no ASN. The name says which one this is.
Sourcepub fn segments(&self) -> SegmentIntoIter
pub fn segments(&self) -> SegmentIntoIter
Returns the path’s segments after the same RFC 6793 merge and coalesce the owned AsPath
applies, so their boundaries match elem.as_path exactly.
A single-segment path keeps its ASNs inline; a path with more than one segment, or with a segment of more than six ASNs, allocates for the part that does not fit.
Sourcepub fn iter(&self) -> AsPathIter<'a> ⓘ
pub fn iter(&self) -> AsPathIter<'a> ⓘ
Returns a zero-allocation iterator over all Asns in the path, expanding AS_SET
segments inline on the fly.
Sourcepub fn to_vec(&self) -> Vec<Asn>
pub fn to_vec(&self) -> Vec<Asn>
Materialises all Asns in this path (with AS_SET expanded in wire order) into a Vec.
Sourcepub fn to_as_path(&self) -> Option<AsPath>
pub fn to_as_path(&self) -> Option<AsPath>
Converts this view into an owned Option<AsPath> matching BgpElem::as_path.
Trait Implementations§
Source§impl<'a> Clone for AsPathView<'a>
impl<'a> Clone for AsPathView<'a>
impl<'a> Copy for AsPathView<'a>
Source§impl<'a> Debug for AsPathView<'a>
impl<'a> Debug for AsPathView<'a>
Source§impl<'a> IntoIterator for AsPathView<'a>
impl<'a> IntoIterator for AsPathView<'a>
Auto Trait Implementations§
impl<'a> Forget for AsPathView<'a>
impl<'a> Freeze for AsPathView<'a>
impl<'a> Move for AsPathView<'a>
impl<'a> RefUnwindSafe for AsPathView<'a>
impl<'a> Send for AsPathView<'a>
impl<'a> Sync for AsPathView<'a>
impl<'a> Unpin for AsPathView<'a>
impl<'a> UnsafeUnpin for AsPathView<'a>where
&'a [u8]: UnsafeUnpin,
impl<'a> UnwindSafe for AsPathView<'a>where
&'a [u8]: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more