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