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