Struct SocketAddr
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§
§impl SocketAddr
impl SocketAddr
pub 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”.
pub 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.
pub fn is_specified(&self) -> bool
pub fn is_specified(&self) -> bool
Query whether both the address and the port are specified.
Trait Implementations§
§impl Clone for SocketAddr
impl Clone for SocketAddr
§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
§impl Debug for SocketAddr
impl Debug for SocketAddr
§impl Display for SocketAddr
impl Display for SocketAddr
impl Eq for SocketAddr
§impl Format for SocketAddr
impl Format for SocketAddr
§impl<T> From<(T, u16)> for SocketAddr
impl<T> From<(T, u16)> for SocketAddr
§fn from(_: (T, u16)) -> SocketAddr
fn from(_: (T, u16)) -> SocketAddr
Converts to this type from the input type.
§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.§fn from(x: SocketAddr) -> SocketAddr
fn from(x: SocketAddr) -> SocketAddr
Converts to this type from the input type.
§impl From<SocketAddr> for ListenSocketAddr
impl From<SocketAddr> for ListenSocketAddr
§fn from(addr: SocketAddr) -> ListenSocketAddr
fn from(addr: SocketAddr) -> ListenSocketAddr
Converts to this type from the input type.
§impl FromStr for SocketAddr
impl FromStr for SocketAddr
§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
§fn from_str(s: &str) -> Result<SocketAddr, ParseError>
fn from_str(s: &str) -> Result<SocketAddr, ParseError>
Parses a string
s to return a value of this type. Read more§impl Hash for SocketAddr
impl Hash for SocketAddr
§impl Ord for SocketAddr
impl Ord for SocketAddr
§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
§impl PartialEq for SocketAddr
impl PartialEq for SocketAddr
§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