diff options
| author | Jethro Beekman <jethro@fortanix.com> | 2018-09-18 15:25:08 -0700 |
|---|---|---|
| committer | Jethro Beekman <jethro@fortanix.com> | 2018-12-06 20:37:15 +0530 |
| commit | 22c43689937a81cf5ad6ecfe22d9e63e3cebed04 (patch) | |
| tree | 137d0de6228d8ec2527b2c151c874b8d20e5b0cd /src/libstd/sys/cloudabi | |
| parent | 030b1ed7f709539f5ca422758e9fe00d173aee76 (diff) | |
| download | rust-22c43689937a81cf5ad6ecfe22d9e63e3cebed04.tar.gz rust-22c43689937a81cf5ad6ecfe22d9e63e3cebed04.zip | |
Refactor net::each_addr/lookup_host to forward error from resolve
Diffstat (limited to 'src/libstd/sys/cloudabi')
| -rw-r--r-- | src/libstd/sys/cloudabi/shims/net.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 93eaf6a9e7d..7229e71d175 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -13,13 +13,14 @@ use io; use net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use time::Duration; use sys::{unsupported, Void}; +use convert::TryFrom; pub extern crate libc as netc; pub struct TcpStream(Void); impl TcpStream { - pub fn connect(_: &SocketAddr) -> io::Result<TcpStream> { + pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> { unsupported() } @@ -105,7 +106,7 @@ impl fmt::Debug for TcpStream { pub struct TcpListener(Void); impl TcpListener { - pub fn bind(_: &SocketAddr) -> io::Result<TcpListener> { + pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> { unsupported() } @@ -155,7 +156,7 @@ impl fmt::Debug for TcpListener { pub struct UdpSocket(Void); impl UdpSocket { - pub fn bind(_: &SocketAddr) -> io::Result<UdpSocket> { + pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> { unsupported() } @@ -271,7 +272,7 @@ impl UdpSocket { match self.0 {} } - pub fn connect(&self, _: &SocketAddr) -> io::Result<()> { + pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { match self.0 {} } } @@ -284,6 +285,12 @@ impl fmt::Debug for UdpSocket { pub struct LookupHost(Void); +impl LookupHost { + pub fn port(&self) -> u16 { + match self.0 {} + } +} + impl Iterator for LookupHost { type Item = SocketAddr; fn next(&mut self) -> Option<SocketAddr> { @@ -291,6 +298,18 @@ impl Iterator for LookupHost { } } -pub fn lookup_host(_: &str) -> io::Result<LookupHost> { - unsupported() +impl<'a> TryFrom<&'a str> for LookupHost { + type Error = io::Error; + + fn try_from(_v: &'a str) -> io::Result<LookupHost> { + unsupported() + } +} + +impl<'a> TryFrom<(&'a str, u16)> for LookupHost { + type Error = io::Error; + + fn try_from(_v: (&'a str, u16)) -> io::Result<LookupHost> { + unsupported() + } } |
