pub struct SocketAddr {
pub addr: Address,
pub port: u16,
}Expand description
An IP address and a port.
SocketAddr names one peer: both the address and the port are meant to be
specified. UNSPECIFIED is the one exception, a
sentinel for “no address given” where an API defaults it from elsewhere.
UdpSocket::send_with takes the socket’s
connected remote for it.
See also ListenSocketAddr, the address of a bind, whose address is
optional so that it can match more than one of our addresses.
Fields§
§addr: Address§port: u16Implementations§
Source§impl SocketAddr
impl SocketAddr
Sourcepub const UNSPECIFIED: SocketAddr
pub const UNSPECIFIED: SocketAddr
The wildcard address: unspecified address, port zero. Not a destination anything can be sent to, but a sentinel for “no address given”.
Sourcepub const fn new(addr: Address, port: u16) -> SocketAddr
pub const fn new(addr: Address, port: u16) -> SocketAddr
Create a socket address from an address and a port.
Sourcepub fn is_specified(&self) -> bool
pub fn is_specified(&self) -> bool
Query whether both the address and the port are specified.
Trait Implementations§
Source§impl Clone for SocketAddr
impl Clone for SocketAddr
Source§fn clone(&self) -> SocketAddr
fn clone(&self) -> SocketAddr
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SocketAddr
Source§impl Debug for SocketAddr
impl Debug for SocketAddr
Source§impl Display for SocketAddr
impl Display for SocketAddr
impl Eq for SocketAddr
Source§impl<T: Into<Address>> From<(T, u16)> for SocketAddr
impl<T: Into<Address>> From<(T, u16)> for SocketAddr
Source§fn from((addr, port): (T, u16)) -> SocketAddr
fn from((addr, port): (T, u16)) -> SocketAddr
Converts to this type from the input type.
Source§impl From<SocketAddr> for SocketAddr
Available on crate features ipv4 and ipv6 only.
impl From<SocketAddr> for SocketAddr
Available on crate features
ipv4 and ipv6 only.Source§fn from(x: SocketAddr) -> SocketAddr
fn from(x: SocketAddr) -> SocketAddr
Converts to this type from the input type.
Source§impl From<SocketAddr> for SocketAddr
impl From<SocketAddr> for SocketAddr
Source§fn from(x: SocketAddr) -> SocketAddr
fn from(x: SocketAddr) -> SocketAddr
Converts to this type from the input type.
Source§impl From<SocketAddr> for ListenSocketAddr
impl From<SocketAddr> for ListenSocketAddr
Source§fn from(addr: SocketAddr) -> ListenSocketAddr
fn from(addr: SocketAddr) -> ListenSocketAddr
Converts to this type from the input type.
Source§impl FromStr for SocketAddr
impl FromStr for SocketAddr
Source§impl Hash for SocketAddr
impl Hash for SocketAddr
Source§impl Ord for SocketAddr
impl Ord for SocketAddr
Source§fn cmp(&self, other: &SocketAddr) -> Ordering
fn cmp(&self, other: &SocketAddr) -> Ordering
1.21.0 (const: unstable) · 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 SocketAddr
impl PartialEq for SocketAddr
Source§impl PartialOrd for SocketAddr
impl PartialOrd for SocketAddr
impl StructuralPartialEq for SocketAddr
Auto Trait Implementations§
impl Freeze for SocketAddr
impl RefUnwindSafe for SocketAddr
impl Send for SocketAddr
impl Sync for SocketAddr
impl Unpin for SocketAddr
impl UnsafeUnpin for SocketAddr
impl UnwindSafe for SocketAddr
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