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>

source

pub fn new(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()).

source

pub fn into_addr_scope_id(self) -> (A, Z)

Consumes this AddrAndZone, returning the address and zone separately.

source

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

Translates the zone identifier using the provided function.

source

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.

source

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

Accesses the addr for this AddrAndZone.

source§

impl<A, Z> AddrAndZone<A, Z>

source

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.

Trait Implementations§

source§

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

source§

fn clone(&self) -> AddrAndZone<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 AddrAndZone<A, Z>

source§

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

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

impl<A: ScopeableAddress + Display, Z: Display> Display for AddrAndZone<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: GenericOverIp<I>, I: Ip, Z> GenericOverIp<I> for AddrAndZone<A, Z>

§

type Type = AddrAndZone<<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 AddrAndZone<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 AddrAndZone<A, Z>

source§

fn eq(&self, other: &AddrAndZone<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 AddrAndZone<A, Z>

source§

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

source§

impl<A, Z> StructuralEq for AddrAndZone<A, Z>

source§

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

Auto Trait Implementations§

§

impl<A, Z> RefUnwindSafe for AddrAndZone<A, Z>where A: RefUnwindSafe, Z: RefUnwindSafe,

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.