pub struct ListenSocketAddr {
pub addr: Option<Address>,
pub port: u16,
}Expand description
An optional IP address and a port, for binding.
In contrast with SocketAddr, ListenSocketAddr allows leaving the address
unspecified, in order to listen on a given port at more than one of our
addresses. The address field has three states, which are exactly the three
ways a bind can be scoped:
None: any address, of either IP version, a dual-stack bind.Some(addr)with an unspecified address (0.0.0.0/::): any address of that version, and none of the other one.Some(addr)with a concrete address: that address alone.
It can be constructed from a port alone, in which case the address
is None, and from an (address, port) pair, in which case it is Some. So
(Ipv4Addr::UNSPECIFIED, 80) is the “any IPv4 address” bind, and
(Ipv6Addr::UNSPECIFIED, 80) the IPv6 one.
Fields§
§addr: Option<Address>§port: u16Implementations§
Source§impl ListenSocketAddr
impl ListenSocketAddr
Sourcepub const UNSPECIFIED: ListenSocketAddr
pub const UNSPECIFIED: ListenSocketAddr
The fully wildcard address: any address of any version, port zero.
Sourcepub fn concrete_addr(&self) -> Option<Address>
pub fn concrete_addr(&self) -> Option<Address>
The address, if it is a concrete one, neither absent nor unspecified. That is, one of our addresses rather than a filter over several.
Sourcepub fn version(&self) -> Option<Version>
pub fn version(&self) -> Option<Version>
The IP version this is restricted to, if it is restricted to one.
Sourcepub fn is_specified(&self) -> bool
pub fn is_specified(&self) -> bool
Query whether this names one concrete address and a nonzero port.
Trait Implementations§
Source§impl Clone for ListenSocketAddr
impl Clone for ListenSocketAddr
Source§fn clone(&self) -> ListenSocketAddr
fn clone(&self) -> ListenSocketAddr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ListenSocketAddr
Source§impl Debug for ListenSocketAddr
impl Debug for ListenSocketAddr
Source§impl Default for ListenSocketAddr
impl Default for ListenSocketAddr
Source§fn default() -> ListenSocketAddr
fn default() -> ListenSocketAddr
Source§impl Display for ListenSocketAddr
impl Display for ListenSocketAddr
impl Eq for ListenSocketAddr
Source§impl<T: Into<Address>> From<(T, u16)> for ListenSocketAddr
impl<T: Into<Address>> From<(T, u16)> for ListenSocketAddr
Source§fn from((addr, port): (T, u16)) -> ListenSocketAddr
fn from((addr, port): (T, u16)) -> ListenSocketAddr
Source§impl From<SocketAddr> for ListenSocketAddr
impl From<SocketAddr> for ListenSocketAddr
Source§fn from(addr: SocketAddr) -> ListenSocketAddr
fn from(addr: SocketAddr) -> ListenSocketAddr
Source§impl From<SocketAddr> for ListenSocketAddr
Available on crate features ipv4 and ipv6 only.
impl From<SocketAddr> for ListenSocketAddr
ipv4 and ipv6 only.