Trait axstd::net::ToSocketAddrs
source · pub trait ToSocketAddrs {
type Iter: Iterator<Item = SocketAddr>;
// Required method
fn to_socket_addrs(&self) -> Result<Self::Iter>;
}
net
only.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_addrs
is the identity function. -
SocketAddrV4
,(IpAddr, u16)
,(Ipv4Addr, u16)
:to_socket_addrs
constructs aSocketAddr
trivially. -
(&str, u16)
:&str
should be either a string representation of anIpAddr
address as expected byFromStr
implementation or a host name.u16
is the port number. -
&str
: the string should be either a string representation of aSocketAddr
as expected by itsFromStr
implementation or a string like<host_name>:<port>
pair where<port>
is au16
value.
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 SocketAddr
s.