]> git.proxmox.com Git - rustc.git/blame - src/libstd/sys/wasm/net.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / libstd / sys / wasm / net.rs
CommitLineData
60c5eb7d 1use crate::convert::TryFrom;
532ac7d7 2use crate::fmt;
48663c56 3use crate::io::{self, IoSlice, IoSliceMut};
60c5eb7d 4use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
532ac7d7 5use crate::sys::{unsupported, Void};
60c5eb7d 6use crate::time::Duration;
abe05a73
XL
7
8pub struct TcpStream(Void);
9
10impl TcpStream {
0731742a 11 pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> {
abe05a73
XL
12 unsupported()
13 }
14
15 pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
16 unsupported()
17 }
18
19 pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
20 match self.0 {}
21 }
22
23 pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
24 match self.0 {}
25 }
26
27 pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
28 match self.0 {}
29 }
30
31 pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
32 match self.0 {}
33 }
34
35 pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
36 match self.0 {}
37 }
38
39 pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
40 match self.0 {}
41 }
42
48663c56 43 pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
9fa01778
XL
44 match self.0 {}
45 }
46
abe05a73
XL
47 pub fn write(&self, _: &[u8]) -> io::Result<usize> {
48 match self.0 {}
49 }
50
48663c56 51 pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> {
9fa01778
XL
52 match self.0 {}
53 }
54
abe05a73
XL
55 pub fn peer_addr(&self) -> io::Result<SocketAddr> {
56 match self.0 {}
57 }
58
59 pub fn socket_addr(&self) -> io::Result<SocketAddr> {
60 match self.0 {}
61 }
62
63 pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
64 match self.0 {}
65 }
66
67 pub fn duplicate(&self) -> io::Result<TcpStream> {
68 match self.0 {}
69 }
70
71 pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
72 match self.0 {}
73 }
74
75 pub fn nodelay(&self) -> io::Result<bool> {
76 match self.0 {}
77 }
78
79 pub fn set_ttl(&self, _: u32) -> io::Result<()> {
80 match self.0 {}
81 }
82
83 pub fn ttl(&self) -> io::Result<u32> {
84 match self.0 {}
85 }
86
87 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
88 match self.0 {}
89 }
90
91 pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
92 match self.0 {}
93 }
94}
95
96impl fmt::Debug for TcpStream {
532ac7d7 97 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
abe05a73
XL
98 match self.0 {}
99 }
100}
101
102pub struct TcpListener(Void);
103
104impl TcpListener {
0731742a 105 pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
abe05a73
XL
106 unsupported()
107 }
108
109 pub fn socket_addr(&self) -> io::Result<SocketAddr> {
110 match self.0 {}
111 }
112
113 pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
114 match self.0 {}
115 }
116
117 pub fn duplicate(&self) -> io::Result<TcpListener> {
118 match self.0 {}
119 }
120
121 pub fn set_ttl(&self, _: u32) -> io::Result<()> {
122 match self.0 {}
123 }
124
125 pub fn ttl(&self) -> io::Result<u32> {
126 match self.0 {}
127 }
128
129 pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
130 match self.0 {}
131 }
132
133 pub fn only_v6(&self) -> io::Result<bool> {
134 match self.0 {}
135 }
136
137 pub fn take_error(&self) -> io::Result<Option<io::Error>> {
138 match self.0 {}
139 }
140
141 pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
142 match self.0 {}
143 }
144}
145
146impl fmt::Debug for TcpListener {
532ac7d7 147 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
abe05a73
XL
148 match self.0 {}
149 }
150}
151
152pub struct UdpSocket(Void);
153
154impl UdpSocket {
0731742a 155 pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
abe05a73
XL
156 unsupported()
157 }
158
532ac7d7
XL
159 pub fn peer_addr(&self) -> io::Result<SocketAddr> {
160 match self.0 {}
161 }
162
abe05a73
XL
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
60c5eb7d 231 pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
abe05a73
XL
232 match self.0 {}
233 }
234
60c5eb7d 235 pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
abe05a73
XL
236 match self.0 {}
237 }
238
60c5eb7d 239 pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
abe05a73
XL
240 match self.0 {}
241 }
242
60c5eb7d 243 pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
abe05a73
XL
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
0731742a 275 pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> {
abe05a73
XL
276 match self.0 {}
277 }
278}
279
280impl fmt::Debug for UdpSocket {
532ac7d7 281 fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
abe05a73
XL
282 match self.0 {}
283 }
284}
285
286pub struct LookupHost(Void);
287
0731742a
XL
288impl LookupHost {
289 pub fn port(&self) -> u16 {
290 match self.0 {}
291 }
292}
293
abe05a73
XL
294impl Iterator for LookupHost {
295 type Item = SocketAddr;
296 fn next(&mut self) -> Option<SocketAddr> {
297 match self.0 {}
298 }
299}
300
532ac7d7 301impl TryFrom<&str> for LookupHost {
0731742a
XL
302 type Error = io::Error;
303
532ac7d7 304 fn try_from(_v: &str) -> io::Result<LookupHost> {
0731742a
XL
305 unsupported()
306 }
307}
308
309impl<'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 }
abe05a73
XL
315}
316
b7449926 317#[allow(nonstandard_style)]
abe05a73
XL
318pub mod netc {
319 pub const AF_INET: u8 = 0;
320 pub const AF_INET6: u8 = 1;
321 pub type sa_family_t = u8;
322
323 #[derive(Copy, Clone)]
324 pub struct in_addr {
325 pub s_addr: u32,
326 }
327
328 #[derive(Copy, Clone)]
329 pub struct sockaddr_in {
330 pub sin_family: sa_family_t,
331 pub sin_port: u16,
332 pub sin_addr: in_addr,
333 }
334
335 #[derive(Copy, Clone)]
336 pub struct in6_addr {
337 pub s6_addr: [u8; 16],
338 }
339
340 #[derive(Copy, Clone)]
341 pub struct sockaddr_in6 {
342 pub sin6_family: sa_family_t,
343 pub sin6_port: u16,
344 pub sin6_addr: in6_addr,
345 pub sin6_flowinfo: u32,
346 pub sin6_scope_id: u32,
347 }
348
349 #[derive(Copy, Clone)]
60c5eb7d 350 pub struct sockaddr {}
abe05a73
XL
351
352 pub type socklen_t = usize;
353}