]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unix/l4re.rs
Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippy
[rust.git] / library / std / src / sys / unix / l4re.rs
1 macro_rules! unimpl {
2     () => {
3         return Err(io::const_io_error!(
4             io::ErrorKind::Unsupported,
5             "No networking available on L4Re.",
6         ));
7     };
8 }
9
10 pub mod net {
11     #![allow(warnings)]
12     use crate::fmt;
13     use crate::io::{self, IoSlice, IoSliceMut};
14     use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
15     use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
16     use crate::sys::fd::FileDesc;
17     use crate::sys_common::{AsInner, FromInner, IntoInner};
18     use crate::time::Duration;
19
20     #[allow(unused_extern_crates)]
21     pub extern crate libc as netc;
22
23     pub struct Socket(FileDesc);
24     impl Socket {
25         pub fn new(_: &SocketAddr, _: libc::c_int) -> io::Result<Socket> {
26             unimpl!();
27         }
28
29         pub fn new_raw(_: libc::c_int, _: libc::c_int) -> io::Result<Socket> {
30             unimpl!();
31         }
32
33         pub fn new_pair(_: libc::c_int, _: libc::c_int) -> io::Result<(Socket, Socket)> {
34             unimpl!();
35         }
36
37         pub fn connect_timeout(&self, _: &SocketAddr, _: Duration) -> io::Result<()> {
38             unimpl!();
39         }
40
41         pub fn accept(
42             &self,
43             _: *mut libc::sockaddr,
44             _: *mut libc::socklen_t,
45         ) -> io::Result<Socket> {
46             unimpl!();
47         }
48
49         pub fn duplicate(&self) -> io::Result<Socket> {
50             unimpl!();
51         }
52
53         pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
54             unimpl!();
55         }
56
57         pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
58             unimpl!();
59         }
60
61         pub fn is_read_vectored(&self) -> bool {
62             false
63         }
64
65         pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
66             unimpl!();
67         }
68
69         pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
70             unimpl!();
71         }
72
73         pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
74             unimpl!();
75         }
76
77         pub fn write(&self, _: &[u8]) -> io::Result<usize> {
78             unimpl!();
79         }
80
81         pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> {
82             unimpl!();
83         }
84
85         pub fn is_write_vectored(&self) -> bool {
86             false
87         }
88
89         pub fn set_timeout(&self, _: Option<Duration>, _: libc::c_int) -> io::Result<()> {
90             unimpl!();
91         }
92
93         pub fn timeout(&self, _: libc::c_int) -> io::Result<Option<Duration>> {
94             unimpl!();
95         }
96
97         pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
98             unimpl!();
99         }
100
101         pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
102             unimpl!();
103         }
104
105         pub fn linger(&self) -> io::Result<Option<Duration>> {
106             unimpl!();
107         }
108
109         pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
110             unimpl!();
111         }
112
113         pub fn nodelay(&self) -> io::Result<bool> {
114             unimpl!();
115         }
116
117         pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
118             unimpl!();
119         }
120
121         pub fn take_error(&self) -> io::Result<Option<io::Error>> {
122             unimpl!();
123         }
124
125         // This is used by sys_common code to abstract over Windows and Unix.
126         pub fn as_raw(&self) -> RawFd {
127             self.as_raw_fd()
128         }
129     }
130
131     impl AsInner<FileDesc> for Socket {
132         fn as_inner(&self) -> &FileDesc {
133             &self.0
134         }
135     }
136
137     impl FromInner<FileDesc> for Socket {
138         fn from_inner(file_desc: FileDesc) -> Socket {
139             Socket(file_desc)
140         }
141     }
142
143     impl IntoInner<FileDesc> for Socket {
144         fn into_inner(self) -> FileDesc {
145             self.0
146         }
147     }
148
149     impl AsFd for Socket {
150         fn as_fd(&self) -> BorrowedFd<'_> {
151             self.0.as_fd()
152         }
153     }
154
155     impl AsRawFd for Socket {
156         fn as_raw_fd(&self) -> RawFd {
157             self.0.as_raw_fd()
158         }
159     }
160
161     impl IntoRawFd for Socket {
162         fn into_raw_fd(self) -> RawFd {
163             self.0.into_raw_fd()
164         }
165     }
166
167     impl FromRawFd for Socket {
168         unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
169             Self(FromRawFd::from_raw_fd(raw_fd))
170         }
171     }
172
173     pub struct TcpStream {
174         inner: Socket,
175     }
176
177     impl TcpStream {
178         pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> {
179             unimpl!();
180         }
181
182         pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> {
183             unimpl!();
184         }
185
186         pub fn socket(&self) -> &Socket {
187             &self.inner
188         }
189
190         pub fn into_socket(self) -> Socket {
191             self.inner
192         }
193
194         pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
195             unimpl!();
196         }
197
198         pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
199             unimpl!();
200         }
201
202         pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
203             unimpl!();
204         }
205
206         pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
207             unimpl!();
208         }
209
210         pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
211             unimpl!();
212         }
213
214         pub fn read(&self, _: &mut [u8]) -> io::Result<usize> {
215             unimpl!();
216         }
217
218         pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
219             unimpl!();
220         }
221
222         pub fn is_read_vectored(&self) -> bool {
223             false
224         }
225
226         pub fn write(&self, _: &[u8]) -> io::Result<usize> {
227             unimpl!();
228         }
229
230         pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> {
231             unimpl!();
232         }
233
234         pub fn is_write_vectored(&self) -> bool {
235             false
236         }
237
238         pub fn peer_addr(&self) -> io::Result<SocketAddr> {
239             unimpl!();
240         }
241
242         pub fn socket_addr(&self) -> io::Result<SocketAddr> {
243             unimpl!();
244         }
245
246         pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
247             unimpl!();
248         }
249
250         pub fn duplicate(&self) -> io::Result<TcpStream> {
251             unimpl!();
252         }
253
254         pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
255             unimpl!();
256         }
257
258         pub fn linger(&self) -> io::Result<Option<Duration>> {
259             unimpl!();
260         }
261
262         pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
263             unimpl!();
264         }
265
266         pub fn nodelay(&self) -> io::Result<bool> {
267             unimpl!();
268         }
269
270         pub fn set_ttl(&self, _: u32) -> io::Result<()> {
271             unimpl!();
272         }
273
274         pub fn ttl(&self) -> io::Result<u32> {
275             unimpl!();
276         }
277
278         pub fn take_error(&self) -> io::Result<Option<io::Error>> {
279             unimpl!();
280         }
281
282         pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
283             unimpl!();
284         }
285     }
286
287     impl FromInner<Socket> for TcpStream {
288         fn from_inner(socket: Socket) -> TcpStream {
289             TcpStream { inner: socket }
290         }
291     }
292
293     impl fmt::Debug for TcpStream {
294         fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
295             write!(f, "No networking support available on L4Re")
296         }
297     }
298
299     pub struct TcpListener {
300         inner: Socket,
301     }
302
303     impl TcpListener {
304         pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
305             unimpl!();
306         }
307
308         pub fn socket(&self) -> &Socket {
309             &self.inner
310         }
311
312         pub fn into_socket(self) -> Socket {
313             self.inner
314         }
315
316         pub fn socket_addr(&self) -> io::Result<SocketAddr> {
317             unimpl!();
318         }
319
320         pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
321             unimpl!();
322         }
323
324         pub fn duplicate(&self) -> io::Result<TcpListener> {
325             unimpl!();
326         }
327
328         pub fn set_ttl(&self, _: u32) -> io::Result<()> {
329             unimpl!();
330         }
331
332         pub fn ttl(&self) -> io::Result<u32> {
333             unimpl!();
334         }
335
336         pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
337             unimpl!();
338         }
339
340         pub fn only_v6(&self) -> io::Result<bool> {
341             unimpl!();
342         }
343
344         pub fn take_error(&self) -> io::Result<Option<io::Error>> {
345             unimpl!();
346         }
347
348         pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
349             unimpl!();
350         }
351     }
352
353     impl FromInner<Socket> for TcpListener {
354         fn from_inner(socket: Socket) -> TcpListener {
355             TcpListener { inner: socket }
356         }
357     }
358
359     impl fmt::Debug for TcpListener {
360         fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
361             write!(f, "No networking support available on L4Re.")
362         }
363     }
364
365     pub struct UdpSocket {
366         inner: Socket,
367     }
368
369     impl UdpSocket {
370         pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
371             unimpl!();
372         }
373
374         pub fn socket(&self) -> &Socket {
375             &self.inner
376         }
377
378         pub fn into_socket(self) -> Socket {
379             self.inner
380         }
381
382         pub fn peer_addr(&self) -> io::Result<SocketAddr> {
383             unimpl!();
384         }
385
386         pub fn socket_addr(&self) -> io::Result<SocketAddr> {
387             unimpl!();
388         }
389
390         pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
391             unimpl!();
392         }
393
394         pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
395             unimpl!();
396         }
397
398         pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> {
399             unimpl!();
400         }
401
402         pub fn duplicate(&self) -> io::Result<UdpSocket> {
403             unimpl!();
404         }
405
406         pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
407             unimpl!();
408         }
409
410         pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
411             unimpl!();
412         }
413
414         pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
415             unimpl!();
416         }
417
418         pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
419             unimpl!();
420         }
421
422         pub fn set_broadcast(&self, _: bool) -> io::Result<()> {
423             unimpl!();
424         }
425
426         pub fn broadcast(&self) -> io::Result<bool> {
427             unimpl!();
428         }
429
430         pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> {
431             unimpl!();
432         }
433
434         pub fn multicast_loop_v4(&self) -> io::Result<bool> {
435             unimpl!();
436         }
437
438         pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> {
439             unimpl!();
440         }
441
442         pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
443             unimpl!();
444         }
445
446         pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> {
447             unimpl!();
448         }
449
450         pub fn multicast_loop_v6(&self) -> io::Result<bool> {
451             unimpl!();
452         }
453
454         pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
455             unimpl!();
456         }
457
458         pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
459             unimpl!();
460         }
461
462         pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
463             unimpl!();
464         }
465
466         pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
467             unimpl!();
468         }
469
470         pub fn set_ttl(&self, _: u32) -> io::Result<()> {
471             unimpl!();
472         }
473
474         pub fn ttl(&self) -> io::Result<u32> {
475             unimpl!();
476         }
477
478         pub fn take_error(&self) -> io::Result<Option<io::Error>> {
479             unimpl!();
480         }
481
482         pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
483             unimpl!();
484         }
485
486         pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> {
487             unimpl!();
488         }
489
490         pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
491             unimpl!();
492         }
493
494         pub fn send(&self, _: &[u8]) -> io::Result<usize> {
495             unimpl!();
496         }
497
498         pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> {
499             unimpl!();
500         }
501     }
502
503     impl FromInner<Socket> for UdpSocket {
504         fn from_inner(socket: Socket) -> UdpSocket {
505             UdpSocket { inner: socket }
506         }
507     }
508
509     impl fmt::Debug for UdpSocket {
510         fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
511             write!(f, "No networking support on L4Re available.")
512         }
513     }
514
515     pub struct LookupHost {
516         original: *mut libc::addrinfo,
517         cur: *mut libc::addrinfo,
518     }
519
520     impl Iterator for LookupHost {
521         type Item = SocketAddr;
522         fn next(&mut self) -> Option<SocketAddr> {
523             None
524         }
525     }
526
527     impl LookupHost {
528         pub fn port(&self) -> u16 {
529             0 // unimplemented
530         }
531     }
532
533     unsafe impl Sync for LookupHost {}
534     unsafe impl Send for LookupHost {}
535
536     impl TryFrom<&str> for LookupHost {
537         type Error = io::Error;
538
539         fn try_from(_v: &str) -> io::Result<LookupHost> {
540             unimpl!();
541         }
542     }
543
544     impl<'a> TryFrom<(&'a str, u16)> for LookupHost {
545         type Error = io::Error;
546
547         fn try_from(_v: (&'a str, u16)) -> io::Result<LookupHost> {
548             unimpl!();
549         }
550     }
551 }