Enum net_types::ip::IpAddr

source ·
pub enum IpAddr<V4 = Ipv4Addr, V6 = Ipv6Addr> {
    V4(V4),
    V6(V6),
}
Expand description

An IP address.

By default, the contained address types are Ipv4Addr and Ipv6Addr. However, any types can be provided. This is intended to support types like IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>. From is implemented to support conversions in both directions between IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>> and SpecifiedAddr<IpAddr>, and similarly for other witness types.

Variants§

§

V4(V4)

§

V6(V6)

Implementations§

source§

impl<V4, V6> IpAddr<V4, V6>

source

pub fn transpose<W: IpAddrWitness<V4 = V4, V6 = V6>>(self) -> W

Transposes an IpAddr of a witness type to a witness type of an IpAddr.

For example, transpose can be used to convert an IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>> into a SpecifiedAddr<IpAddr<Ipv4Addr, Ipv6Addr>>.

Trait Implementations§

source§

impl<V4: Clone, V6: Clone> Clone for IpAddr<V4, V6>

source§

fn clone(&self) -> IpAddr<V4, V6>

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<V4: Debug, V6: Debug> Debug for IpAddr<V4, V6>

source§

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

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

impl<V4: Display, V6: Display> Display for IpAddr<V4, V6>

source§

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

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

impl<A: IpAddress, const N: usize> From<[A; N]> for IpAddr<[Ipv4Addr; N], [Ipv6Addr; N]>

source§

fn from(addrs: [A; N]) -> Self

Converts to this type from the input type.
source§

impl<A: IpAddress> From<A> for IpAddr

source§

fn from(addr: A) -> IpAddr

Converts to this type from the input type.
source§

impl From<IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>>> for LinkLocalAddr<IpAddr>

source§

fn from( addr: IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>> ) -> LinkLocalAddr<IpAddr>

Converts to this type from the input type.
source§

impl From<IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>>> for MulticastAddr<IpAddr>

source§

fn from( addr: IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>> ) -> MulticastAddr<IpAddr>

Converts to this type from the input type.
source§

impl From<IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>>> for NonMappedAddr<IpAddr>

source§

fn from( addr: IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>> ) -> NonMappedAddr<IpAddr>

Converts to this type from the input type.
source§

impl From<IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>> for SpecifiedAddr<IpAddr>

source§

fn from( addr: IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>> ) -> SpecifiedAddr<IpAddr>

Converts to this type from the input type.
source§

impl From<IpAddr> for IpAddr

source§

fn from(addr: IpAddr) -> IpAddr

Converts to this type from the input type.
source§

impl From<IpAddr> for IpAddr

source§

fn from(addr: IpAddr) -> IpAddr

Converts to this type from the input type.
source§

impl<A: IpAddress> From<LinkLocalAddr<A>> for IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>>

source§

fn from( addr: LinkLocalAddr<A> ) -> IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl From<LinkLocalAddr<IpAddr>> for IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>>

source§

fn from( addr: LinkLocalAddr<IpAddr> ) -> IpAddr<LinkLocalAddr<Ipv4Addr>, LinkLocalAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl<A: IpAddress> From<MulticastAddr<A>> for IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>>

source§

fn from( addr: MulticastAddr<A> ) -> IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl From<MulticastAddr<IpAddr>> for IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>>

source§

fn from( addr: MulticastAddr<IpAddr> ) -> IpAddr<MulticastAddr<Ipv4Addr>, MulticastAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl<A: IpAddress> From<NonMappedAddr<A>> for IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>>

source§

fn from( addr: NonMappedAddr<A> ) -> IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl From<NonMappedAddr<IpAddr>> for IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>>

source§

fn from( addr: NonMappedAddr<IpAddr> ) -> IpAddr<NonMappedAddr<Ipv4Addr>, NonMappedAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl<A: IpAddress> From<SpecifiedAddr<A>> for IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>

source§

fn from( addr: SpecifiedAddr<A> ) -> IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl From<SpecifiedAddr<IpAddr>> for IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>

source§

fn from( addr: SpecifiedAddr<IpAddr> ) -> IpAddr<SpecifiedAddr<Ipv4Addr>, SpecifiedAddr<Ipv6Addr>>

Converts to this type from the input type.
source§

impl<V4: Hash, V6: Hash> Hash for IpAddr<V4, V6>

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 LinkLocalAddress for IpAddr

Is this address link-local?

source§

impl MappedAddress for IpAddr

source§

fn is_non_mapped(&self) -> bool

Is this address non-mapped?

source§

impl MulticastAddress for IpAddr

source§

fn is_multicast(&self) -> bool

Is this an address in the multicast subnet?

is_multicast returns true if self is in Ip::MULTICAST_SUBNET for the IP version of this address.

source§

impl<V4: Ord, V6: Ord> Ord for IpAddr<V4, V6>

source§

fn cmp(&self, other: &IpAddr<V4, V6>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<V4: PartialEq, V6: PartialEq> PartialEq for IpAddr<V4, V6>

source§

fn eq(&self, other: &IpAddr<V4, V6>) -> 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<V4: PartialOrd, V6: PartialOrd> PartialOrd for IpAddr<V4, V6>

source§

fn partial_cmp(&self, other: &IpAddr<V4, V6>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Scope for IpAddr<(), Ipv6Scope>

source§

fn can_have_zone(&self) -> bool

Can addresses in this scope have an associated zone?
source§

impl ScopeableAddress for IpAddr

§

type Scope = IpAddr<(), Ipv6Scope>

The type of all non-global scopes.
source§

fn scope(&self) -> IpAddr<(), Ipv6Scope>

The scope of this address. Read more
source§

impl SpecifiedAddress for IpAddr

source§

fn is_specified(&self) -> bool

Is this an address other than the unspecified address?

is_specified returns true if self is not equal to Ip::UNSPECIFIED_ADDRESS for the IP version of this address.

source§

impl<V4: Copy, V6: Copy> Copy for IpAddr<V4, V6>

source§

impl<V4: Eq, V6: Eq> Eq for IpAddr<V4, V6>

source§

impl<V4, V6> StructuralPartialEq for IpAddr<V4, V6>

Auto Trait Implementations§

§

impl<V4, V6> RefUnwindSafe for IpAddr<V4, V6>

§

impl<V4, V6> Send for IpAddr<V4, V6>
where V4: Send, V6: Send,

§

impl<V4, V6> Sync for IpAddr<V4, V6>
where V4: Sync, V6: Sync,

§

impl<V4, V6> Unpin for IpAddr<V4, V6>
where V4: Unpin, V6: Unpin,

§

impl<V4, V6> UnwindSafe for IpAddr<V4, V6>
where V4: UnwindSafe, V6: 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.
source§

impl<A> LinkLocalMulticastAddress for A