#[non_exhaustive]
pub enum IpAddress {
Unspecified,
Ipv4(Ipv4Address),
Ipv6(Ipv6Address),
}
Expand description
An internetworking address.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Unspecified
An unspecified address. May be used as a placeholder for storage where the address is not assigned yet.
Ipv4(Ipv4Address)
An IPv4 address.
Ipv6(Ipv6Address)
An IPv6 address.
Implementations
sourceimpl Address
impl Address
sourcepub fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address
pub fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address
Create an address wrapping an IPv4 address with the given octets.
sourcepub fn v6(
a0: u16,
a1: u16,
a2: u16,
a3: u16,
a4: u16,
a5: u16,
a6: u16,
a7: u16
) -> Address
pub fn v6(
a0: u16,
a1: u16,
a2: u16,
a3: u16,
a4: u16,
a5: u16,
a6: u16,
a7: u16
) -> Address
Create an address wrapping an IPv6 address with the given octets.
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Return an address as a sequence of octets, in big-endian.
sourcepub fn is_unicast(&self) -> bool
pub fn is_unicast(&self) -> bool
Query whether the address is a valid unicast address.
sourcepub fn is_multicast(&self) -> bool
pub fn is_multicast(&self) -> bool
Query whether the address is a valid multicast address.
sourcepub fn is_broadcast(&self) -> bool
pub fn is_broadcast(&self) -> bool
Query whether the address is the broadcast address.
sourcepub fn is_unspecified(&self) -> bool
pub fn is_unspecified(&self) -> bool
Query whether the address falls into the “unspecified” range.
sourcepub fn as_unspecified(&self) -> Address
pub fn as_unspecified(&self) -> Address
Return an unspecified address that has the same IP version as self
.
sourcepub fn prefix_len(&self) -> Option<u8>
pub fn prefix_len(&self) -> Option<u8>
If self
is a CIDR-compatible subnet mask, return Some(prefix_len)
,
where prefix_len
is the number of leading zeroes. Return None
otherwise.
Trait Implementations
sourceimpl From<Address> for Address
impl From<Address> for Address
sourcefn from(addr: Ipv4Address) -> Self
fn from(addr: Ipv4Address) -> Self
Converts to this type from the input type.
sourceimpl From<Address> for Address
impl From<Address> for Address
sourcefn from(addr: Ipv6Address) -> Self
fn from(addr: Ipv6Address) -> Self
Converts to this type from the input type.
sourceimpl Ord for Address
impl Ord for Address
sourceimpl PartialOrd<Address> for Address
impl PartialOrd<Address> for Address
sourcefn partial_cmp(&self, other: &Address) -> Option<Ordering>
fn partial_cmp(&self, other: &Address) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl Copy for Address
impl Eq for Address
impl StructuralEq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more