pub enum SocketAddress {
IpV4(SocketAddressV4),
IpV6(SocketAddressV6),
}Expand description
An IP socket address, either IPv4 or IPv6, with a specific port.
Instead of using std::net::SocketAddr, this implementation
is geared towards no_std environments and zerocopy decoding.
The size is also consistent across target operating systems.
Variants§
IpV4(SocketAddressV4)
IpV6(SocketAddressV6)
Implementations§
Source§impl SocketAddress
impl SocketAddress
pub fn ip(&self) -> IpAddress
pub fn port(&self) -> u16
pub fn set_port(&mut self, port: u16)
pub const fn unicast_scope(&self) -> Option<UnicastScope>
Sourcepub fn to_ipv6_mapped(self) -> SocketAddressV6
pub fn to_ipv6_mapped(self) -> SocketAddressV6
Converts the IP address into a IPv6 mapped address
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
Trait Implementations§
Source§impl Clone for SocketAddress
impl Clone for SocketAddress
Source§fn clone(&self) -> SocketAddress
fn clone(&self) -> SocketAddress
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SocketAddress
impl Debug for SocketAddress
Source§impl Default for SocketAddress
impl Default for SocketAddress
Source§impl Display for SocketAddress
impl Display for SocketAddress
Source§impl From<SocketAddr> for SocketAddress
impl From<SocketAddr> for SocketAddress
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddress> for LocalAddress
impl From<SocketAddress> for LocalAddress
Source§fn from(value: SocketAddress) -> Self
fn from(value: SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddress> for RemoteAddress
impl From<SocketAddress> for RemoteAddress
Source§fn from(value: SocketAddress) -> Self
fn from(value: SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddress> for SocketAddr
impl From<SocketAddress> for SocketAddr
Source§fn from(address: SocketAddress) -> Self
fn from(address: SocketAddress) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddressV4> for SocketAddress
impl From<SocketAddressV4> for SocketAddress
Source§fn from(addr: SocketAddressV4) -> Self
fn from(addr: SocketAddressV4) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddressV6> for SocketAddress
impl From<SocketAddressV6> for SocketAddress
Source§fn from(addr: SocketAddressV6) -> Self
fn from(addr: SocketAddressV6) -> Self
Converts to this type from the input type.
Source§impl Hash for SocketAddress
impl Hash for SocketAddress
Source§impl<'a> IntoEvent<SocketAddress<'a>> for &'a SocketAddress
impl<'a> IntoEvent<SocketAddress<'a>> for &'a SocketAddress
fn into_event(self) -> SocketAddress<'a>
Source§impl<'a> IntoEvent<SocketAddress<'a>> for &'a SocketAddress
impl<'a> IntoEvent<SocketAddress<'a>> for &'a SocketAddress
fn into_event(self) -> SocketAddress<'a>
Source§impl Ord for SocketAddress
impl Ord for SocketAddress
Source§fn cmp(&self, other: &SocketAddress) -> Ordering
fn cmp(&self, other: &SocketAddress) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SocketAddress
impl PartialEq for SocketAddress
Source§impl PartialOrd for SocketAddress
impl PartialOrd for SocketAddress
Source§impl ToSocketAddrs for SocketAddress
impl ToSocketAddrs for SocketAddress
Source§type Iter = Once<SocketAddr>
type Iter = Once<SocketAddr>
Returned iterator over socket addresses which this type may correspond
to.
Source§fn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
Converts this object to an iterator of resolved
SocketAddrs. Read moreSource§impl Unspecified for SocketAddress
impl Unspecified for SocketAddress
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 SocketAddress
impl Eq for SocketAddress
impl StructuralPartialEq for SocketAddress
Auto Trait Implementations§
impl Freeze for SocketAddress
impl RefUnwindSafe for SocketAddress
impl Send for SocketAddress
impl Sync for SocketAddress
impl Unpin for SocketAddress
impl UnwindSafe for SocketAddress
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