[][src]Trait no_std_net::ToSocketAddrs

pub trait ToSocketAddrs {
    type Iter: Iterator<Item = SocketAddr>;
    pub fn to_socket_addrs(&self) -> Result<Self::Iter, ToSocketAddrError>;
}

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:

This trait allows constructing network objects like TcpStream or UdpSocket easily with values of various types for the bind/connection address. It is needed because sometimes one type is more appropriate than the other: for simple uses a string like "localhost:12345" is much nicer than manual construction of the corresponding SocketAddr, but sometimes SocketAddr value is the main source of the address, and converting it to some other type (e.g. a string) just for it to be converted back to SocketAddr in constructor methods is pointless.

Addresses returned by the operating system that are not IP addresses are silently ignored.

Associated Types

type Iter: Iterator<Item = SocketAddr>[src]

Returned iterator over socket addresses which this type may correspond to.

Loading content...

Required methods

pub fn to_socket_addrs(&self) -> Result<Self::Iter, ToSocketAddrError>[src]

Converts this object to an iterator of resolved SocketAddrs.

The returned iterator may not actually yield any values depending on the outcome of any resolution performed.

Note that this function may block the current thread while resolution is performed.

Loading content...

Implementors

impl ToSocketAddrs for (IpAddr, u16)[src]

type Iter = IntoIter<SocketAddr>

impl ToSocketAddrs for (Ipv4Addr, u16)[src]

type Iter = IntoIter<SocketAddr>

impl ToSocketAddrs for (Ipv6Addr, u16)[src]

type Iter = IntoIter<SocketAddr>

impl ToSocketAddrs for SocketAddr[src]

type Iter = IntoIter<SocketAddr>

impl ToSocketAddrs for SocketAddrV4[src]

type Iter = IntoIter<SocketAddr>

impl ToSocketAddrs for SocketAddrV6[src]

type Iter = IntoIter<SocketAddr>

impl<'a> ToSocketAddrs for &'a [SocketAddr][src]

type Iter = Cloned<Iter<'a, SocketAddr>>

impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T[src]

type Iter = T::Iter

Loading content...