Enum net_types::ZonedAddr

source ·
pub enum ZonedAddr<A, Z> {
    Unzoned(A),
    Zoned(AddrAndZone<A, Z>),
}
Expand description

An address that may have an associated scope zone.

Variants§

§

Unzoned(A)

§

Zoned(AddrAndZone<A, Z>)

Implementations§

source§

impl<A, Z> ZonedAddr<A, Z>

source

pub fn into_addr_zone(self) -> (A, Option<Z>)

Decomposes this ZonedAddr into an addr and an optional scope zone.

source

pub fn addr(&self) -> A
where A: Copy,

Accesses the addr for this ZonedAddr.

source

pub fn map_zone<Y>(self, f: impl FnOnce(Z) -> Y) -> ZonedAddr<A, Y>

Translates the zone identifier using the provided function.

source

pub fn map_addr<B>(self, f: impl FnOnce(A) -> B) -> ZonedAddr<B, Z>

Translates the address using f.

source

pub fn as_ref(&self) -> ZonedAddr<&A, &Z>

Converts from &ZonedAddr<A, Z> to ZonedAddr<&A, &Z>.

source§

impl<A: ScopeableAddress, Z> ZonedAddr<A, Z>

source

pub fn new(addr: A, zone: Option<Z>) -> Option<Self>

Creates a new ZonedAddr with the provided optional scope zone.

If zone is None, ZonedAddr::Unzoned is returned. Otherwise, a ZonedAddr::Zoned is returned only if the provided addr’s scope can have a zone (addr.scope().can_have_zone()).

source§

impl<A: IpAddress + ScopeableAddress, Z: Clone> ZonedAddr<A, Z>

source

pub fn new_zoned_if_necessary(addr: A, get_zone: impl FnOnce() -> Z) -> Self

Creates a ZonedAddr::Zoned iff addr can have a zone and is not loopback.

get_zone is only called if the address needs a zone.

source§

impl<A: ScopeableAddress<Scope = ()>, Z> ZonedAddr<A, Z>

source

pub fn into_unzoned(self) -> A

Retrieves the addr for this ZonedAddr when the Scope is ().

() is a known implementation that never allows AddrAndZone to be constructed so we can safely drop the zone information.

Trait Implementations§

source§

impl<A: Clone, Z: Clone> Clone for ZonedAddr<A, Z>

source§

fn clone(&self) -> ZonedAddr<A, Z>

Returns a copy 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<A: Debug, Z: Debug> Debug for ZonedAddr<A, Z>

source§

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

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

impl<A: Display, Z: Display> Display for ZonedAddr<A, Z>

source§

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

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

impl<A, Z> From<AddrAndZone<A, Z>> for ZonedAddr<A, Z>

source§

fn from(a: AddrAndZone<A, Z>) -> Self

Converts to this type from the input type.
source§

impl<A: SpecifiedAddress, Z> From<ZonedAddr<SpecifiedAddr<A>, Z>> for ZonedAddr<A, Z>

source§

fn from(zoned_addr: ZonedAddr<SpecifiedAddr<A>, Z>) -> Self

Converts to this type from the input type.
source§

impl<A: GenericOverIp<I>, I: Ip, Z> GenericOverIp<I> for ZonedAddr<A, Z>

§

type Type = ZonedAddr<<A as GenericOverIp<I>>::Type, Z>

The type of Self when its IP-generic parameter is replaced with the type NewIp.
source§

impl<A: Hash, Z: Hash> Hash for ZonedAddr<A, Z>

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<A: PartialEq, Z: PartialEq> PartialEq for ZonedAddr<A, Z>

source§

fn eq(&self, other: &ZonedAddr<A, Z>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Copy, Z: Copy> Copy for ZonedAddr<A, Z>

source§

impl<A: Eq, Z: Eq> Eq for ZonedAddr<A, Z>

source§

impl<A, Z> StructuralPartialEq for ZonedAddr<A, Z>

Auto Trait Implementations§

§

impl<A, Z> Freeze for ZonedAddr<A, Z>
where A: Freeze, Z: Freeze,

§

impl<A, Z> RefUnwindSafe for ZonedAddr<A, Z>

§

impl<A, Z> Send for ZonedAddr<A, Z>
where A: Send, Z: Send,

§

impl<A, Z> Sync for ZonedAddr<A, Z>
where A: Sync, Z: Sync,

§

impl<A, Z> Unpin for ZonedAddr<A, Z>
where A: Unpin, Z: Unpin,

§

impl<A, Z> UnwindSafe for ZonedAddr<A, Z>
where A: UnwindSafe, Z: UnwindSafe,

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> 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,

§

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§

default 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>,

§

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>,

§

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.