Skip to main content

Attributes

Struct Attributes 

Source
pub struct Attributes { /* private fields */ }
Expand description

Convenience wrapper for a list of attributes

Implementations§

Source§

impl Attributes

Source

pub fn has_attr(&self, ty: AttrType) -> bool

Source

pub fn get_attr(&self, ty: AttrType) -> Option<Attribute>

Source

pub fn add_attr(&mut self, attr: Attribute)

Source

pub fn check_mandatory_attributes( &mut self, is_announcement: bool, has_standard_nlri: bool, )

Check for missing well-known mandatory attributes.

RFC 4271 (BGP-4) and RFC 4760 (MP-BGP) define which attributes are mandatory.

  • Pure Withdrawals: NO path attributes are required.
  • Announcements: ORIGIN and AS_PATH are strictly required.
  • NEXT_HOP is required if standard IPv4 NLRI is present or if no MP_REACH_NLRI is present.
Source

pub fn add_validation_warning(&mut self, warning: BgpValidationWarning)

Add a validation warning to the attributes

Source

pub fn validation_warnings(&self) -> &[BgpValidationWarning]

Get all validation warnings for these attributes

Source

pub fn has_validation_warnings(&self) -> bool

Check if there are any validation warnings

Source

pub fn origin(&self) -> Origin

Get the ORIGIN attribute. In the event that this attribute is not present, Origin::INCOMPLETE will be returned instead.

Source

pub fn origin_id(&self) -> Option<BgpIdentifier>

Get the ORIGINATOR_ID attribute if present.

Source

pub fn next_hop(&self) -> Option<IpAddr>

Get the NEXT_HOP attribute if present.

Note: Even when this attribute is not present, the next hop address may still be attainable from the MP_REACH_NLRI attribute.

Source

pub fn multi_exit_discriminator(&self) -> Option<u32>

Source

pub fn local_preference(&self) -> Option<u32>

Source

pub fn only_to_customer(&self) -> Option<Asn>

Source

pub fn atomic_aggregate(&self) -> bool

Source

pub fn aggregator(&self) -> Option<(Asn, BgpIdentifier)>

Source

pub fn clusters(&self) -> Option<&[u32]>

Source

pub fn as_path(&self) -> Option<&AsPath>

Source

pub fn get_reachable_nlri(&self) -> Option<&Nlri>

Source

pub fn get_unreachable_nlri(&self) -> Option<&Nlri>

Source

pub fn iter_communities(&self) -> MetaCommunitiesIter<'_>

Source

pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter

Get an iterator over the held AttributeValues. If you also need attribute flags, consider using Attributes::into_attributes_iter instead.

Source

pub fn into_attributes_iter(self) -> impl Iterator<Item = Attribute>

Get an iterator over the held Attributes. If you do no not need attribute flags, consider using Attributes::iter instead.

Source§

impl Attributes

Source

pub fn encode(&self, asn_len: AsnLength) -> Bytes

Trait Implementations§

Source§

impl Clone for Attributes

Source§

fn clone(&self) -> Attributes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attributes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Attributes

Source§

fn default() -> Attributes

Returns the “default value” for a type. Read more
Source§

impl Eq for Attributes

Source§

impl Extend<Attribute> for Attributes

Source§

fn extend<T: IntoIterator<Item = Attribute>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<AttributeValue> for Attributes

Source§

fn extend<T: IntoIterator<Item = AttributeValue>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&BgpElem> for Attributes

Source§

fn from(value: &BgpElem) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Attribute>> for Attributes

Source§

fn from(value: Vec<Attribute>) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Attribute> for Attributes

Source§

fn from_iter<T: IntoIterator<Item = Attribute>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<AttributeValue> for Attributes

Source§

fn from_iter<T: IntoIterator<Item = AttributeValue>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl IntoIterator for Attributes

Source§

type Item = AttributeValue

The type of the elements being iterated over.
Source§

type IntoIter = Map<IntoIter<Attribute>, fn(Attribute) -> AttributeValue>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a Attributes

Source§

type Item = &'a AttributeValue

The type of the elements being iterated over.
Source§

type IntoIter = Map<Iter<'a, Attribute>, fn(&Attribute) -> &AttributeValue>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Attributes

Source§

fn eq(&self, other: &Attributes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Attributes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more