Skip to main content

ExtendedCommunity

Struct ExtendedCommunity 

Source
pub struct ExtendedCommunity(/* private fields */);
Expand description

RFC 4360 Extended Community — 8-byte value stored as u64.

Wire layout: type (1) + sub-type (1) + value (6). Bit 6 of the type byte: 0 = transitive, 1 = non-transitive.

Implementations§

Source§

impl ExtendedCommunity

Source

pub fn new(raw: u64) -> Self

Create from a raw 8-byte value.

Source

pub fn as_u64(self) -> u64

Return the raw 8-byte value.

Source

pub fn type_byte(self) -> u8

High byte — IANA-assigned type.

Source

pub fn subtype(self) -> u8

Second byte — sub-type within the type.

Source

pub fn is_transitive(self) -> bool

Transitive if bit 6 of the type byte is 0.

Source

pub fn value_bytes(self) -> [u8; 6]

Bytes 2-7 of the community value.

Source

pub fn route_target(self) -> Option<(u32, u32)>

Decode as Route Target (sub-type 0x02).

Returns (global_admin, local_admin) as raw u32 values. The interpretation of global_admin depends on the type byte:

  • Type 0x00 (2-octet AS specific): global = ASN (fits u16), local = u32
  • Type 0x01 (IPv4 address specific): global = IPv4 addr as u32, local = u16
  • Type 0x02 (4-octet AS specific): global = ASN (u32), local = u16

Callers that need to distinguish these encodings (e.g. for display as RT:192.0.2.1:100 vs RT:65001:100) must also check type_byte().

Source

pub fn route_origin(self) -> Option<(u32, u32)>

Decode as Route Origin (sub-type 0x03).

Same layout as route_target() — returns raw (global_admin, local_admin) with the same type-byte-dependent interpretation. Check type_byte() to distinguish 2-octet AS, IPv4-address, and 4-octet AS encodings.

Source§

impl ExtendedCommunity

Source

pub fn as_flowspec_action(&self) -> Option<FlowSpecAction>

Try to decode this extended community as a FlowSpec action.

Source

pub fn from_flowspec_action(action: &FlowSpecAction) -> Self

Create an extended community from a FlowSpec action.

Trait Implementations§

Source§

impl Clone for ExtendedCommunity

Source§

fn clone(&self) -> ExtendedCommunity

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ExtendedCommunity

Source§

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

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

impl Display for ExtendedCommunity

Source§

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

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

impl Hash for ExtendedCommunity

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ExtendedCommunity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for ExtendedCommunity

Source§

impl Eq for ExtendedCommunity

Source§

impl StructuralPartialEq for ExtendedCommunity

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.