pub enum IpAddress {
Ipv4(IpV4Address),
Ipv6(IpV6Address),
}Expand description
An IP address, either IPv4 or IPv6.
Instead of using std::net::IPAddr, this implementation
is geared towards no_std environments and zerocopy decoding.
The size is also consistent across target operating systems.
Variants§
Ipv4(IpV4Address)
Ipv6(IpV6Address)
Implementations§
Source§impl IpAddress
impl IpAddress
Sourcepub fn unmap(self) -> Self
pub fn unmap(self) -> Self
Converts the IP address into IPv4 if it is mapped, otherwise the address is unchanged
Sourcepub fn unmapped_eq(&self, other: &Self) -> bool
pub fn unmapped_eq(&self, other: &Self) -> bool
Returns true if the two addresses are equal from a network perspective.
This will unmap IPv4-mapped addresses to IpV4 tagged enum values
Sourcepub fn to_ipv6_mapped(self) -> IpV6Address
pub fn to_ipv6_mapped(self) -> IpV6Address
Converts the IP address into IPv6 if it is IPv4, otherwise the address is unchanged
pub fn with_port(self, port: u16) -> SocketAddress
Trait Implementations§
Source§impl From<IpV4Address> for IpAddress
impl From<IpV4Address> for IpAddress
Source§fn from(ip: IpV4Address) -> Self
fn from(ip: IpV4Address) -> Self
Converts to this type from the input type.
Source§impl From<IpV6Address> for IpAddress
impl From<IpV6Address> for IpAddress
Source§fn from(ip: IpV6Address) -> Self
fn from(ip: IpV6Address) -> Self
Converts to this type from the input type.
Source§impl Ord for IpAddress
impl Ord for IpAddress
Source§impl PartialOrd for IpAddress
impl PartialOrd for IpAddress
Source§impl Unspecified for IpAddress
impl Unspecified for IpAddress
Source§fn is_unspecified(&self) -> bool
fn is_unspecified(&self) -> bool
Returns true if the value is unspecified
Source§fn filter_unspecified(self) -> Option<Self>
fn filter_unspecified(self) -> Option<Self>
Coerce a potentially unspecified value into an
Option<Self>impl Copy for IpAddress
impl Eq for IpAddress
impl StructuralPartialEq for IpAddress
Auto Trait Implementations§
impl Freeze for IpAddress
impl RefUnwindSafe for IpAddress
impl Send for IpAddress
impl Sync for IpAddress
impl Unpin for IpAddress
impl UnwindSafe for IpAddress
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
Mutably borrows from an owned value. Read more