]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/wasm/net.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / libstd / sys / wasm / 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::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
14 use time::Duration;
15 use sys::{unsupported, Void};
16
17 pub struct TcpStream(Void);
18
19 impl TcpStream {
20 pub fn connect(_: &SocketAddr) -> io::Result<TcpStream> {
21 unsupported()
22 }
23
24 pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
25 unsupported()
26 }
27
28 pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
29 match self.0 {}
30 }
31
32 pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
33 match self.0 {}
34 }
35
36 pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
37 match self.0 {}
38 }
39
40 pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
41 match self.0 {}
42 }
43
44 pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
45 match self.0 {}
46 }
47
48 pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
49 match self.0 {}
50 }
51
52 pub fn write(&self, _: &[u8]) -> io::Result<usize> {
53 match self.0 {}
54 }
55
56 pub fn peer_addr(&self) -> io::Result<SocketAddr> {
57 match self.0 {}
58 }
59
60 pub fn socket_addr(&self) -> io::Result<SocketAddr> {
61 match self.0 {}
62 }
63
64 pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
65 match self.0 {}
66 }
67
68 pub fn duplicate(&self) -> io::Result<TcpStream> {
69 match self.0 {}
70 }
71
72 pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
73 match self.0 {}
74 }
75
76 pub fn nodelay(&self) -> io::Result<bool> {
77 match self.0 {}
78 }
79
80 pub fn set_ttl(&self, _: u32) -> io::Result<()> {
81 match self.0 {}
82 }
83
84 pub fn ttl(&self) -> io::Result<u32> {
85 match self.0 {}
86 }
87
88 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
89 match self.0 {}
90 }
91
92 pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
93 match self.0 {}
94 }
95 }
96
97 impl fmt::Debug for TcpStream {
98 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
99 match self.0 {}
100 }
101 }
102
103 pub struct TcpListener(Void);
104
105 impl TcpListener {
106 pub fn bind(_: &SocketAddr) -> io::Result<TcpListener> {
107 unsupported()
108 }
109
110 pub fn socket_addr(&self) -> io::Result<SocketAddr> {
111 match self.0 {}
112 }
113
114 pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
115 match self.0 {}
116 }
117
118 pub fn duplicate(&self) -> io::Result<TcpListener> {
119 match self.0 {}
120 }
121
122 pub fn set_ttl(&self, _: u32) -> io::Result<()> {
123 match self.0 {}
124 }
125
126 pub fn ttl(&self) -> io::Result<u32> {
127 match self.0 {}
128 }
129
130 pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
131 match self.0 {}
132 }
133
134 pub fn only_v6(&self) -> io::Result<bool> {
135 match self.0 {}
136 }
137
138 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
139 match self.0 {}
140 }
141
142 pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
143 match self.0 {}
144 }
145 }
146
147 impl fmt::Debug for TcpListener {
148 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
149 match self.0 {}
150 }
151 }
152
153 pub struct UdpSocket(Void);
154
155 impl UdpSocket {
156 pub fn bind(_: &SocketAddr) -> io::Result<UdpSocket> {
157 unsupported()
158 }
159
160 pub fn socket_addr(&self) -> io::Result<SocketAddr> {
161 match self.0 {}
162 }
163
164 pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
165 match self.0 {}
166 }
167
168 pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
169 match self.0 {}
170 }
171
172 pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> {
173 match self.0 {}
174 }
175
176 pub fn duplicate(&self) -> io::Result<UdpSocket> {
177 match self.0 {}
178 }
179
180 pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
181 match self.0 {}
182 }
183
184 pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
185 match self.0 {}
186 }
187
188 pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
189 match self.0 {}
190 }
191
192 pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
193 match self.0 {}
194 }
195
196 pub fn set_broadcast(&self, _: bool) -> io::Result<()> {
197 match self.0 {}
198 }
199
200 pub fn broadcast(&self) -> io::Result<bool> {
201 match self.0 {}
202 }
203
204 pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> {
205 match self.0 {}
206 }
207
208 pub fn multicast_loop_v4(&self) -> io::Result<bool> {
209 match self.0 {}
210 }
211
212 pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> {
213 match self.0 {}
214 }
215
216 pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
217 match self.0 {}
218 }
219
220 pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> {
221 match self.0 {}
222 }
223
224 pub fn multicast_loop_v6(&self) -> io::Result<bool> {
225 match self.0 {}
226 }
227
228 pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
229 -> io::Result<()> {
230 match self.0 {}
231 }
232
233 pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32)
234 -> io::Result<()> {
235 match self.0 {}
236 }
237
238 pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
239 -> io::Result<()> {
240 match self.0 {}
241 }
242
243 pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32)
244 -> io::Result<()> {
245 match self.0 {}
246 }
247
248 pub fn set_ttl(&self, _: u32) -> io::Result<()> {
249 match self.0 {}
250 }
251
252 pub fn ttl(&self) -> io::Result<u32> {
253 match self.0 {}
254 }
255
256 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
257 match self.0 {}
258 }
259
260 pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
261 match self.0 {}
262 }
263
264 pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> {
265 match self.0 {}
266 }
267
268 pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
269 match self.0 {}
270 }
271
272 pub fn send(&self, _: &[u8]) -> io::Result<usize> {
273 match self.0 {}
274 }
275
276 pub fn connect(&self, _: &SocketAddr) -> io::Result<()> {
277 match self.0 {}
278 }
279 }
280
281 impl fmt::Debug for UdpSocket {
282 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
283 match self.0 {}
284 }
285 }
286
287 pub struct LookupHost(Void);
288
289 impl Iterator for LookupHost {
290 type Item = SocketAddr;
291 fn next(&mut self) -> Option<SocketAddr> {
292 match self.0 {}
293 }
294 }
295
296 pub fn lookup_host(_: &str) -> io::Result<LookupHost> {
297 unsupported()
298 }
299
300 #[allow(bad_style)]
301 pub mod netc {
302 pub const AF_INET: u8 = 0;
303 pub const AF_INET6: u8 = 1;
304 pub type sa_family_t = u8;
305
306 #[derive(Copy, Clone)]
307 pub struct in_addr {
308 pub s_addr: u32,
309 }
310
311 #[derive(Copy, Clone)]
312 pub struct sockaddr_in {
313 pub sin_family: sa_family_t,
314 pub sin_port: u16,
315 pub sin_addr: in_addr,
316 }
317
318 #[derive(Copy, Clone)]
319 pub struct in6_addr {
320 pub s6_addr: [u8; 16],
321 }
322
323 #[derive(Copy, Clone)]
324 pub struct sockaddr_in6 {
325 pub sin6_family: sa_family_t,
326 pub sin6_port: u16,
327 pub sin6_addr: in6_addr,
328 pub sin6_flowinfo: u32,
329 pub sin6_scope_id: u32,
330 }
331
332 #[derive(Copy, Clone)]
333 pub struct sockaddr {
334 }
335
336 pub type socklen_t = usize;
337 }