pub trait ToSocketAddrs {
type Iter: Iterator<Item = SocketAddr>;
// Required method
fn to_socket_addrs(&self) -> Result<Self::Iter>;
}Expand description
A trait for objects which can be converted or resolved to one or more
SocketAddr values.
This trait is used for generic address resolution when constructing network objects. By default it is implemented for the following types:
-
SocketAddr:to_socket_addrsis the identity function. -
SocketAddrV4,(IpAddr, u16),(Ipv4Addr, u16):to_socket_addrsconstructs aSocketAddrtrivially. -
(&str, u16):&strshould be either a string representation of anIpAddraddress as expected byFromStrimplementation or a host name.u16is the port number. -
&str: the string should be either a string representation of aSocketAddras expected by itsFromStrimplementation or a string like<host_name>:<port>pair where<port>is au16value.
Required Associated Types§
Sourcetype Iter: Iterator<Item = SocketAddr>
type Iter: Iterator<Item = SocketAddr>
Returned iterator over socket addresses which this type may correspond to.
Required Methods§
Sourcefn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
Converts this object to an iterator of resolved SocketAddrs.
Implementations on Foreign Types§
Source§impl ToSocketAddrs for (&str, u16)
Available on crate feature net only.
impl ToSocketAddrs for (&str, u16)
net only.type Iter = IntoIter<SocketAddr>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
Source§impl ToSocketAddrs for (IpAddr, u16)
impl ToSocketAddrs for (IpAddr, u16)
type Iter = IntoIter<SocketAddr>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
Source§impl ToSocketAddrs for (String, u16)
Available on crate feature net only.
impl ToSocketAddrs for (String, u16)
net only.type Iter = IntoIter<SocketAddr>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
Source§impl ToSocketAddrs for (Ipv4Addr, u16)
impl ToSocketAddrs for (Ipv4Addr, u16)
type Iter = IntoIter<SocketAddr>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
Source§impl ToSocketAddrs for str
Available on crate feature net only.
impl ToSocketAddrs for str
net only.type Iter = IntoIter<SocketAddr>
fn to_socket_addrs(&self) -> Result<IntoIter<SocketAddr>>
Source§impl ToSocketAddrs for String
Available on crate feature net only.
impl ToSocketAddrs for String
net only.