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