]> git.lizzy.rs Git - rust.git/blob - src/libstd/sys/cloudabi/shims/net.rs
Refactor net::each_addr/lookup_host to forward error from resolve
[rust.git] / src / libstd / sys / cloudabi / shims / net.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use fmt;
12 use io;
13 use net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
14 use time::Duration;
15 use sys::{unsupported, Void};
16 use convert::TryFrom;
17
18 pub extern crate libc as netc;
19
20 pub struct TcpStream(Void);
21
22 impl TcpStream {
23     pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> {
24         unsupported()
25     }
26
27     pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
28         unsupported()
29     }
30
31     pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
32         match self.0 {}
33     }
34
35     pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
36         match self.0 {}
37     }
38
39     pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
40         match self.0 {}
41     }
42
43     pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
44         match self.0 {}
45     }
46
47     pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
48         match self.0 {}
49     }
50
51     pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
52         match self.0 {}
53     }
54
55     pub fn write(&self, _: &[u8]) -> io::Result<usize> {
56         match self.0 {}
57     }
58
59     pub fn peer_addr(&self) -> io::Result<SocketAddr> {
60         match self.0 {}
61     }
62
63     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
64         match self.0 {}
65     }
66
67     pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
68         match self.0 {}
69     }
70
71     pub fn duplicate(&self) -> io::Result<TcpStream> {
72         match self.0 {}
73     }
74
75     pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
76         match self.0 {}
77     }
78
79     pub fn nodelay(&self) -> io::Result<bool> {
80         match self.0 {}
81     }
82
83     pub fn set_ttl(&self, _: u32) -> io::Result<()> {
84         match self.0 {}
85     }
86
87     pub fn ttl(&self) -> io::Result<u32> {
88         match self.0 {}
89     }
90
91     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
92         match self.0 {}
93     }
94
95     pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
96         match self.0 {}
97     }
98 }
99
100 impl fmt::Debug for TcpStream {
101     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
102         match self.0 {}
103     }
104 }
105
106 pub struct TcpListener(Void);
107
108 impl TcpListener {
109     pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
110         unsupported()
111     }
112
113     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
114         match self.0 {}
115     }
116
117     pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
118         match self.0 {}
119     }
120
121     pub fn duplicate(&self) -> io::Result<TcpListener> {
122         match self.0 {}
123     }
124
125     pub fn set_ttl(&self, _: u32) -> io::Result<()> {
126         match self.0 {}
127     }
128
129     pub fn ttl(&self) -> io::Result<u32> {
130         match self.0 {}
131     }
132
133     pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
134         match self.0 {}
135     }
136
137     pub fn only_v6(&self) -> io::Result<bool> {
138         match self.0 {}
139     }
140
141     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
142         match self.0 {}
143     }
144
145     pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
146         match self.0 {}
147     }
148 }
149
150 impl fmt::Debug for TcpListener {
151     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
152         match self.0 {}
153     }
154 }
155
156 pub struct UdpSocket(Void);
157
158 impl UdpSocket {
159     pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
160         unsupported()
161     }
162
163     pub fn socket_addr(&self) -> io::Result<SocketAddr> {
164         match self.0 {}
165     }
166
167     pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
168         match self.0 {}
169     }
170
171     pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
172         match self.0 {}
173     }
174
175     pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> {
176         match self.0 {}
177     }
178
179     pub fn duplicate(&self) -> io::Result<UdpSocket> {
180         match self.0 {}
181     }
182
183     pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
184         match self.0 {}
185     }
186
187     pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
188         match self.0 {}
189     }
190
191     pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
192         match self.0 {}
193     }
194
195     pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
196         match self.0 {}
197     }
198
199     pub fn set_broadcast(&self, _: bool) -> io::Result<()> {
200         match self.0 {}
201     }
202
203     pub fn broadcast(&self) -> io::Result<bool> {
204         match self.0 {}
205     }
206
207     pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> {
208         match self.0 {}
209     }
210
211     pub fn multicast_loop_v4(&self) -> io::Result<bool> {
212         match self.0 {}
213     }
214
215     pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> {
216         match self.0 {}
217     }
218
219     pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
220         match self.0 {}
221     }
222
223     pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> {
224         match self.0 {}
225     }
226
227     pub fn multicast_loop_v6(&self) -> io::Result<bool> {
228         match self.0 {}
229     }
230
231     pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
232         match self.0 {}
233     }
234
235     pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
236         match self.0 {}
237     }
238
239     pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
240         match self.0 {}
241     }
242
243     pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
244         match self.0 {}
245     }
246
247     pub fn set_ttl(&self, _: u32) -> io::Result<()> {
248         match self.0 {}
249     }
250
251     pub fn ttl(&self) -> io::Result<u32> {
252         match self.0 {}
253     }
254
255     pub fn take_error(&self) -> io::Result<Option<io::Error>> {
256         match self.0 {}
257     }
258
259     pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
260         match self.0 {}
261     }
262
263     pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> {
264         match self.0 {}
265     }
266
267     pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
268         match self.0 {}
269     }
270
271     pub fn send(&self, _: &[u8]) -> io::Result<usize> {
272         match self.0 {}
273     }
274
275     pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> {
276         match self.0 {}
277     }
278 }
279
280 impl fmt::Debug for UdpSocket {
281     fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
282         match self.0 {}
283     }
284 }
285
286 pub struct LookupHost(Void);
287
288 impl LookupHost {
289     pub fn port(&self) -> u16 {
290         match self.0 {}
291     }
292 }
293
294 impl Iterator for LookupHost {
295     type Item = SocketAddr;
296     fn next(&mut self) -> Option<SocketAddr> {
297         match self.0 {}
298     }
299 }
300
301 impl<'a> TryFrom<&'a str> for LookupHost {
302     type Error = io::Error;
303
304     fn try_from(_v: &'a str) -> io::Result<LookupHost> {
305         unsupported()
306     }
307 }
308
309 impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
310     type Error = io::Error;
311
312     fn try_from(_v: (&'a str, u16)) -> io::Result<LookupHost> {
313         unsupported()
314     }
315 }