Struct net_types::AddrAndZone
source · pub struct AddrAndZone<A, Z>(/* private fields */);
Expand description
A witness type for an address and a scope zone.
AddrAndZone
carries an address that may have a scope, alongside the
particular zone of that scope. The zone is also referred to as a “scope
identifier” in some systems (such as Linux).
Note that although AddrAndZone
acts as a witness type, it does not
implement Witness
since it carries both the address and scoping
information, and not only the witnessed address.
Implementations§
source§impl<A: ScopeableAddress, Z> AddrAndZone<A, Z>
impl<A: ScopeableAddress, Z> AddrAndZone<A, Z>
source§impl<A: ScopeableAddress + IpAddress, Z> AddrAndZone<A, Z>
impl<A: ScopeableAddress + IpAddress, Z> AddrAndZone<A, Z>
sourcepub fn new_not_loopback(addr: A, zone: Z) -> Option<Self>
pub fn new_not_loopback(addr: A, zone: Z) -> Option<Self>
Constructs a new AddrAndZone
, returning Some
only if the provided
addr
’s scope can have a zone (addr.scope().can_have_zone()
) and
addr
is not a loopback address.
source§impl<A, Z> AddrAndZone<A, Z>
impl<A, Z> AddrAndZone<A, Z>
sourcepub const unsafe fn new_unchecked(addr: A, zone: Z) -> Self
pub const unsafe fn new_unchecked(addr: A, zone: Z) -> Self
Constructs a new AddrAndZone
without checking to see if addr
’s scope
can have a zone.
§Safety
It is up to the caller to make sure that addr
’s scope can have a zone
to avoid breaking the guarantees of AddrAndZone
.
sourcepub fn into_addr_scope_id(self) -> (A, Z)
pub fn into_addr_scope_id(self) -> (A, Z)
Consumes this AddrAndZone
, returning the address and zone separately.
sourcepub fn map_zone<Y>(self, f: impl FnOnce(Z) -> Y) -> AddrAndZone<A, Y>
pub fn map_zone<Y>(self, f: impl FnOnce(Z) -> Y) -> AddrAndZone<A, Y>
Translates the zone identifier using the provided function.
sourcepub fn map_addr<B>(self, f: impl FnOnce(A) -> B) -> AddrAndZone<B, Z>
pub fn map_addr<B>(self, f: impl FnOnce(A) -> B) -> AddrAndZone<B, Z>
Translates the address using f
.
sourcepub fn try_map_zone<Y, E>(
self,
f: impl FnOnce(Z) -> Result<Y, E>,
) -> Result<AddrAndZone<A, Y>, E>
pub fn try_map_zone<Y, E>( self, f: impl FnOnce(Z) -> Result<Y, E>, ) -> Result<AddrAndZone<A, Y>, E>
Attempts to translate the zone identifier using the provided function.
sourcepub fn as_ref(&self) -> AddrAndZone<&A, &Z>
pub fn as_ref(&self) -> AddrAndZone<&A, &Z>
Converts from AddrAndZone<A, Z>
to AddrAndZone<&A, &Z>
.
Trait Implementations§
source§impl<A: Clone, Z: Clone> Clone for AddrAndZone<A, Z>
impl<A: Clone, Z: Clone> Clone for AddrAndZone<A, Z>
source§fn clone(&self) -> AddrAndZone<A, Z>
fn clone(&self) -> AddrAndZone<A, Z>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<A, Z> From<AddrAndZone<A, Z>> for ZonedAddr<A, Z>
impl<A, Z> From<AddrAndZone<A, Z>> for ZonedAddr<A, Z>
source§fn from(a: AddrAndZone<A, Z>) -> Self
fn from(a: AddrAndZone<A, Z>) -> Self
source§impl<A: SpecifiedAddress, Z> From<AddrAndZone<SpecifiedAddr<A>, Z>> for AddrAndZone<A, Z>
impl<A: SpecifiedAddress, Z> From<AddrAndZone<SpecifiedAddr<A>, Z>> for AddrAndZone<A, Z>
source§fn from(AddrAndZone: AddrAndZone<SpecifiedAddr<A>, Z>) -> Self
fn from(AddrAndZone: AddrAndZone<SpecifiedAddr<A>, Z>) -> Self
source§impl<A: GenericOverIp<I>, I: Ip, Z> GenericOverIp<I> for AddrAndZone<A, Z>
impl<A: GenericOverIp<I>, I: Ip, Z> GenericOverIp<I> for AddrAndZone<A, Z>
§type Type = AddrAndZone<<A as GenericOverIp<I>>::Type, Z>
type Type = AddrAndZone<<A as GenericOverIp<I>>::Type, Z>
Self
when its IP-generic parameter is replaced with the
type NewIp
.source§impl<A: PartialEq, Z: PartialEq> PartialEq for AddrAndZone<A, Z>
impl<A: PartialEq, Z: PartialEq> PartialEq for AddrAndZone<A, Z>
source§fn eq(&self, other: &AddrAndZone<A, Z>) -> bool
fn eq(&self, other: &AddrAndZone<A, Z>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<A: Copy, Z: Copy> Copy for AddrAndZone<A, Z>
impl<A: Eq, Z: Eq> Eq for AddrAndZone<A, Z>
impl<A, Z> StructuralPartialEq for AddrAndZone<A, Z>
Auto Trait Implementations§
impl<A, Z> Freeze for AddrAndZone<A, Z>
impl<A, Z> RefUnwindSafe for AddrAndZone<A, Z>where
A: RefUnwindSafe,
Z: RefUnwindSafe,
impl<A, Z> Send for AddrAndZone<A, Z>
impl<A, Z> Sync for AddrAndZone<A, Z>
impl<A, Z> Unpin for AddrAndZone<A, Z>
impl<A, Z> UnwindSafe for AddrAndZone<A, Z>where
A: UnwindSafe,
Z: 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)