]> git.proxmox.com Git - rustc.git/blob - vendor/rustix-0.36.5/src/backend/libc/net/types.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / vendor / rustix-0.36.5 / src / backend / libc / net / types.rs
1 use super::super::c;
2 use bitflags::bitflags;
3
4 /// A type for holding raw integer socket types.
5 #[doc(hidden)]
6 pub type RawSocketType = u32;
7
8 /// `SOCK_*` constants for use with [`socket`].
9 ///
10 /// [`socket`]: crate::net::socket
11 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
12 #[repr(transparent)]
13 pub struct SocketType(pub(crate) RawSocketType);
14
15 #[rustfmt::skip]
16 impl SocketType {
17 /// `SOCK_STREAM`
18 pub const STREAM: Self = Self(c::SOCK_STREAM as u32);
19
20 /// `SOCK_DGRAM`
21 pub const DGRAM: Self = Self(c::SOCK_DGRAM as u32);
22
23 /// `SOCK_SEQPACKET`
24 pub const SEQPACKET: Self = Self(c::SOCK_SEQPACKET as u32);
25
26 /// `SOCK_RAW`
27 pub const RAW: Self = Self(c::SOCK_RAW as u32);
28
29 /// `SOCK_RDM`
30 #[cfg(not(target_os = "haiku"))]
31 pub const RDM: Self = Self(c::SOCK_RDM as u32);
32
33 /// Constructs a `SocketType` from a raw integer.
34 #[inline]
35 pub const fn from_raw(raw: RawSocketType) -> Self {
36 Self(raw)
37 }
38
39 /// Returns the raw integer for this `SocketType`.
40 #[inline]
41 pub const fn as_raw(self) -> RawSocketType {
42 self.0
43 }
44 }
45
46 /// A type for holding raw integer address families.
47 #[doc(hidden)]
48 pub type RawAddressFamily = c::sa_family_t;
49
50 /// `AF_*` constants.
51 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
52 #[repr(transparent)]
53 pub struct AddressFamily(pub(crate) RawAddressFamily);
54
55 #[rustfmt::skip]
56 impl AddressFamily {
57 /// `AF_UNSPEC`
58 pub const UNSPEC: Self = Self(c::AF_UNSPEC as _);
59 /// `AF_INET`
60 pub const INET: Self = Self(c::AF_INET as _);
61 /// `AF_INET6`
62 pub const INET6: Self = Self(c::AF_INET6 as _);
63 /// `AF_NETLINK`
64 #[cfg(not(any(
65 windows,
66 target_os = "dragonfly",
67 target_os = "freebsd",
68 target_os = "haiku",
69 target_os = "illumos",
70 target_os = "ios",
71 target_os = "macos",
72 target_os = "netbsd",
73 target_os = "openbsd",
74 target_os = "solaris",
75 )))]
76 pub const NETLINK: Self = Self(c::AF_NETLINK as _);
77 /// `AF_UNIX`, aka `AF_LOCAL`
78 #[doc(alias = "LOCAL")]
79 pub const UNIX: Self = Self(c::AF_UNIX as _);
80 /// `AF_AX25`
81 #[cfg(not(any(
82 windows,
83 target_os = "dragonfly",
84 target_os = "freebsd",
85 target_os = "haiku",
86 target_os = "illumos",
87 target_os = "ios",
88 target_os = "macos",
89 target_os = "netbsd",
90 target_os = "openbsd",
91 target_os = "solaris",
92 )))]
93 pub const AX25: Self = Self(c::AF_AX25 as _);
94 /// `AF_IPX`
95 pub const IPX: Self = Self(c::AF_IPX as _);
96 /// `AF_APPLETALK`
97 pub const APPLETALK: Self = Self(c::AF_APPLETALK as _);
98 /// `AF_NETROM`
99 #[cfg(not(any(
100 windows,
101 target_os = "dragonfly",
102 target_os = "freebsd",
103 target_os = "haiku",
104 target_os = "illumos",
105 target_os = "ios",
106 target_os = "macos",
107 target_os = "netbsd",
108 target_os = "openbsd",
109 target_os = "solaris",
110 )))]
111 pub const NETROM: Self = Self(c::AF_NETROM as _);
112 /// `AF_BRIDGE`
113 #[cfg(not(any(
114 windows,
115 target_os = "dragonfly",
116 target_os = "freebsd",
117 target_os = "haiku",
118 target_os = "illumos",
119 target_os = "ios",
120 target_os = "macos",
121 target_os = "netbsd",
122 target_os = "openbsd",
123 target_os = "solaris",
124 )))]
125 pub const BRIDGE: Self = Self(c::AF_BRIDGE as _);
126 /// `AF_ATMPVC`
127 #[cfg(not(any(
128 windows,
129 target_os = "dragonfly",
130 target_os = "freebsd",
131 target_os = "haiku",
132 target_os = "illumos",
133 target_os = "ios",
134 target_os = "macos",
135 target_os = "netbsd",
136 target_os = "openbsd",
137 target_os = "solaris",
138 )))]
139 pub const ATMPVC: Self = Self(c::AF_ATMPVC as _);
140 /// `AF_X25`
141 #[cfg(not(any(
142 windows,
143 target_os = "dragonfly",
144 target_os = "freebsd",
145 target_os = "haiku",
146 target_os = "ios",
147 target_os = "macos",
148 target_os = "netbsd",
149 target_os = "openbsd",
150 )))]
151 pub const X25: Self = Self(c::AF_X25 as _);
152 /// `AF_ROSE`
153 #[cfg(not(any(
154 windows,
155 target_os = "dragonfly",
156 target_os = "freebsd",
157 target_os = "haiku",
158 target_os = "illumos",
159 target_os = "ios",
160 target_os = "macos",
161 target_os = "netbsd",
162 target_os = "openbsd",
163 target_os = "solaris",
164 )))]
165 pub const ROSE: Self = Self(c::AF_ROSE as _);
166 /// `AF_DECnet`
167 #[allow(non_upper_case_globals)]
168 #[cfg(not(target_os = "haiku"))]
169 pub const DECnet: Self = Self(c::AF_DECnet as _);
170 /// `AF_NETBEUI`
171 #[cfg(not(any(
172 windows,
173 target_os = "dragonfly",
174 target_os = "freebsd",
175 target_os = "haiku",
176 target_os = "illumos",
177 target_os = "ios",
178 target_os = "macos",
179 target_os = "netbsd",
180 target_os = "openbsd",
181 target_os = "solaris",
182 )))]
183 pub const NETBEUI: Self = Self(c::AF_NETBEUI as _);
184 /// `AF_SECURITY`
185 #[cfg(not(any(
186 windows,
187 target_os = "dragonfly",
188 target_os = "freebsd",
189 target_os = "haiku",
190 target_os = "illumos",
191 target_os = "ios",
192 target_os = "macos",
193 target_os = "netbsd",
194 target_os = "openbsd",
195 target_os = "solaris",
196 )))]
197 pub const SECURITY: Self = Self(c::AF_SECURITY as _);
198 /// `AF_KEY`
199 #[cfg(not(any(
200 windows,
201 target_os = "dragonfly",
202 target_os = "freebsd",
203 target_os = "haiku",
204 target_os = "ios",
205 target_os = "macos",
206 target_os = "netbsd",
207 target_os = "openbsd",
208 )))]
209 pub const KEY: Self = Self(c::AF_KEY as _);
210 /// `AF_PACKET`
211 #[cfg(not(any(
212 windows,
213 target_os = "dragonfly",
214 target_os = "freebsd",
215 target_os = "haiku",
216 target_os = "ios",
217 target_os = "macos",
218 target_os = "netbsd",
219 target_os = "openbsd",
220 )))]
221 pub const PACKET: Self = Self(c::AF_PACKET as _);
222 /// `AF_ASH`
223 #[cfg(not(any(
224 windows,
225 target_os = "dragonfly",
226 target_os = "freebsd",
227 target_os = "haiku",
228 target_os = "illumos",
229 target_os = "ios",
230 target_os = "macos",
231 target_os = "netbsd",
232 target_os = "openbsd",
233 target_os = "solaris",
234 )))]
235 pub const ASH: Self = Self(c::AF_ASH as _);
236 /// `AF_ECONET`
237 #[cfg(not(any(
238 windows,
239 target_os = "dragonfly",
240 target_os = "freebsd",
241 target_os = "haiku",
242 target_os = "illumos",
243 target_os = "ios",
244 target_os = "macos",
245 target_os = "netbsd",
246 target_os = "openbsd",
247 target_os = "solaris",
248 )))]
249 pub const ECONET: Self = Self(c::AF_ECONET as _);
250 /// `AF_ATMSVC`
251 #[cfg(not(any(
252 windows,
253 target_os = "dragonfly",
254 target_os = "freebsd",
255 target_os = "haiku",
256 target_os = "illumos",
257 target_os = "ios",
258 target_os = "macos",
259 target_os = "netbsd",
260 target_os = "openbsd",
261 target_os = "solaris",
262 )))]
263 pub const ATMSVC: Self = Self(c::AF_ATMSVC as _);
264 /// `AF_RDS`
265 #[cfg(not(any(
266 windows,
267 target_os = "dragonfly",
268 target_os = "freebsd",
269 target_os = "haiku",
270 target_os = "illumos",
271 target_os = "ios",
272 target_os = "macos",
273 target_os = "netbsd",
274 target_os = "openbsd",
275 target_os = "solaris",
276 )))]
277 pub const RDS: Self = Self(c::AF_RDS as _);
278 /// `AF_SNA`
279 #[cfg(not(target_os = "haiku"))]
280 pub const SNA: Self = Self(c::AF_SNA as _);
281 /// `AF_IRDA`
282 #[cfg(not(any(
283 target_os = "dragonfly",
284 target_os = "freebsd",
285 target_os = "haiku",
286 target_os = "illumos",
287 target_os = "ios",
288 target_os = "macos",
289 target_os = "netbsd",
290 target_os = "openbsd",
291 target_os = "solaris",
292 )))]
293 pub const IRDA: Self = Self(c::AF_IRDA as _);
294 /// `AF_PPPOX`
295 #[cfg(not(any(
296 windows,
297 target_os = "dragonfly",
298 target_os = "freebsd",
299 target_os = "haiku",
300 target_os = "illumos",
301 target_os = "ios",
302 target_os = "macos",
303 target_os = "netbsd",
304 target_os = "openbsd",
305 target_os = "solaris",
306 )))]
307 pub const PPPOX: Self = Self(c::AF_PPPOX as _);
308 /// `AF_WANPIPE`
309 #[cfg(not(any(
310 windows,
311 target_os = "dragonfly",
312 target_os = "freebsd",
313 target_os = "haiku",
314 target_os = "illumos",
315 target_os = "ios",
316 target_os = "macos",
317 target_os = "netbsd",
318 target_os = "openbsd",
319 target_os = "solaris",
320 )))]
321 pub const WANPIPE: Self = Self(c::AF_WANPIPE as _);
322 /// `AF_LLC`
323 #[cfg(not(any(
324 windows,
325 target_os = "dragonfly",
326 target_os = "freebsd",
327 target_os = "haiku",
328 target_os = "illumos",
329 target_os = "ios",
330 target_os = "macos",
331 target_os = "netbsd",
332 target_os = "openbsd",
333 target_os = "solaris",
334 )))]
335 pub const LLC: Self = Self(c::AF_LLC as _);
336 /// `AF_CAN`
337 #[cfg(not(any(
338 windows,
339 target_os = "dragonfly",
340 target_os = "freebsd",
341 target_os = "haiku",
342 target_os = "illumos",
343 target_os = "ios",
344 target_os = "macos",
345 target_os = "netbsd",
346 target_os = "openbsd",
347 target_os = "solaris",
348 )))]
349 pub const CAN: Self = Self(c::AF_CAN as _);
350 /// `AF_TIPC`
351 #[cfg(not(any(
352 windows,
353 target_os = "dragonfly",
354 target_os = "freebsd",
355 target_os = "haiku",
356 target_os = "illumos",
357 target_os = "ios",
358 target_os = "macos",
359 target_os = "netbsd",
360 target_os = "openbsd",
361 target_os = "solaris",
362 )))]
363 pub const TIPC: Self = Self(c::AF_TIPC as _);
364 /// `AF_BLUETOOTH`
365 #[cfg(not(any(windows, target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
366 pub const BLUETOOTH: Self = Self(c::AF_BLUETOOTH as _);
367 /// `AF_IUCV`
368 #[cfg(not(any(
369 windows,
370 target_os = "dragonfly",
371 target_os = "freebsd",
372 target_os = "haiku",
373 target_os = "illumos",
374 target_os = "ios",
375 target_os = "macos",
376 target_os = "netbsd",
377 target_os = "openbsd",
378 target_os = "solaris",
379 )))]
380 pub const IUCV: Self = Self(c::AF_IUCV as _);
381 /// `AF_RXRPC`
382 #[cfg(not(any(
383 windows,
384 target_os = "dragonfly",
385 target_os = "freebsd",
386 target_os = "haiku",
387 target_os = "illumos",
388 target_os = "ios",
389 target_os = "macos",
390 target_os = "netbsd",
391 target_os = "openbsd",
392 target_os = "solaris",
393 )))]
394 pub const RXRPC: Self = Self(c::AF_RXRPC as _);
395 /// `AF_ISDN`
396 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
397 pub const ISDN: Self = Self(c::AF_ISDN as _);
398 /// `AF_PHONET`
399 #[cfg(not(any(
400 windows,
401 target_os = "dragonfly",
402 target_os = "freebsd",
403 target_os = "haiku",
404 target_os = "illumos",
405 target_os = "ios",
406 target_os = "macos",
407 target_os = "netbsd",
408 target_os = "openbsd",
409 target_os = "solaris",
410 )))]
411 pub const PHONET: Self = Self(c::AF_PHONET as _);
412 /// `AF_IEEE802154`
413 #[cfg(not(any(
414 windows,
415 target_os = "dragonfly",
416 target_os = "freebsd",
417 target_os = "haiku",
418 target_os = "illumos",
419 target_os = "ios",
420 target_os = "macos",
421 target_os = "netbsd",
422 target_os = "openbsd",
423 target_os = "solaris",
424 )))]
425 pub const IEEE802154: Self = Self(c::AF_IEEE802154 as _);
426
427 /// Constructs a `AddressFamily` from a raw integer.
428 #[inline]
429 pub const fn from_raw(raw: RawAddressFamily) -> Self {
430 Self(raw)
431 }
432
433 /// Returns the raw integer for this `AddressFamily`.
434 #[inline]
435 pub const fn as_raw(self) -> RawAddressFamily {
436 self.0
437 }
438 }
439
440 /// A type for holding raw integer protocols.
441 #[doc(hidden)]
442 pub type RawProtocol = i32;
443
444 /// `IPPROTO_*`
445 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
446 #[repr(transparent)]
447 pub struct Protocol(pub(crate) RawProtocol);
448
449 #[rustfmt::skip]
450 impl Protocol {
451 /// `IPPROTO_IP`
452 pub const IP: Self = Self(c::IPPROTO_IP as _);
453 /// `IPPROTO_ICMP`
454 pub const ICMP: Self = Self(c::IPPROTO_ICMP as _);
455 /// `IPPROTO_IGMP`
456 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
457 pub const IGMP: Self = Self(c::IPPROTO_IGMP as _);
458 /// `IPPROTO_IPIP`
459 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
460 pub const IPIP: Self = Self(c::IPPROTO_IPIP as _);
461 /// `IPPROTO_TCP`
462 pub const TCP: Self = Self(c::IPPROTO_TCP as _);
463 /// `IPPROTO_EGP`
464 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
465 pub const EGP: Self = Self(c::IPPROTO_EGP as _);
466 /// `IPPROTO_PUP`
467 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
468 pub const PUP: Self = Self(c::IPPROTO_PUP as _);
469 /// `IPPROTO_UDP`
470 pub const UDP: Self = Self(c::IPPROTO_UDP as _);
471 /// `IPPROTO_IDP`
472 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
473 pub const IDP: Self = Self(c::IPPROTO_IDP as _);
474 /// `IPPROTO_TP`
475 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
476 pub const TP: Self = Self(c::IPPROTO_TP as _);
477 /// `IPPROTO_DCCP`
478 #[cfg(not(any(
479 windows,
480 target_os = "dragonfly",
481 target_os = "haiku",
482 target_os = "illumos",
483 target_os = "ios",
484 target_os = "macos",
485 target_os = "openbsd",
486 target_os = "solaris",
487 )))]
488 pub const DCCP: Self = Self(c::IPPROTO_DCCP as _);
489 /// `IPPROTO_IPV6`
490 pub const IPV6: Self = Self(c::IPPROTO_IPV6 as _);
491 /// `IPPROTO_RSVP`
492 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
493 pub const RSVP: Self = Self(c::IPPROTO_RSVP as _);
494 /// `IPPROTO_GRE`
495 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
496 pub const GRE: Self = Self(c::IPPROTO_GRE as _);
497 /// `IPPROTO_ESP`
498 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
499 pub const ESP: Self = Self(c::IPPROTO_ESP as _);
500 /// `IPPROTO_AH`
501 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
502 pub const AH: Self = Self(c::IPPROTO_AH as _);
503 /// `IPPROTO_MTP`
504 #[cfg(not(any(
505 windows,
506 target_os = "haiku",
507 target_os = "illumos",
508 target_os = "netbsd",
509 target_os = "openbsd",
510 target_os = "solaris",
511 )))]
512 pub const MTP: Self = Self(c::IPPROTO_MTP as _);
513 /// `IPPROTO_BEETPH`
514 #[cfg(not(any(
515 windows,
516 target_os = "dragonfly",
517 target_os = "freebsd",
518 target_os = "haiku",
519 target_os = "illumos",
520 target_os = "ios",
521 target_os = "macos",
522 target_os = "netbsd",
523 target_os = "openbsd",
524 target_os = "solaris",
525 )))]
526 pub const BEETPH: Self = Self(c::IPPROTO_BEETPH as _);
527 /// `IPPROTO_ENCAP`
528 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
529 pub const ENCAP: Self = Self(c::IPPROTO_ENCAP as _);
530 /// `IPPROTO_PIM`
531 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
532 pub const PIM: Self = Self(c::IPPROTO_PIM as _);
533 /// `IPPROTO_COMP`
534 #[cfg(not(any(
535 windows,
536 target_os = "dragonfly",
537 target_os = "freebsd",
538 target_os = "haiku",
539 target_os = "illumos",
540 target_os = "ios",
541 target_os = "macos",
542 target_os = "netbsd",
543 target_os = "openbsd",
544 target_os = "solaris",
545 )))]
546 pub const COMP: Self = Self(c::IPPROTO_COMP as _);
547 /// `IPPROTO_SCTP`
548 #[cfg(not(any(target_os = "dragonfly", target_os = "haiku", target_os = "illumos", target_os = "openbsd", target_os = "solaris")))]
549 pub const SCTP: Self = Self(c::IPPROTO_SCTP as _);
550 /// `IPPROTO_UDPLITE`
551 #[cfg(not(any(
552 windows,
553 target_os = "dragonfly",
554 target_os = "haiku",
555 target_os = "illumos",
556 target_os = "ios",
557 target_os = "macos",
558 target_os = "netbsd",
559 target_os = "openbsd",
560 target_os = "solaris",
561 )))]
562 pub const UDPLITE: Self = Self(c::IPPROTO_UDPLITE as _);
563 /// `IPPROTO_MPLS`
564 #[cfg(not(any(
565 windows,
566 target_os = "dragonfly",
567 target_os = "haiku",
568 target_os = "illumos",
569 target_os = "ios",
570 target_os = "macos",
571 target_os = "netbsd",
572 target_os = "solaris",
573 )))]
574 pub const MPLS: Self = Self(c::IPPROTO_MPLS as _);
575 /// `IPPROTO_RAW`
576 pub const RAW: Self = Self(c::IPPROTO_RAW as _);
577 /// `IPPROTO_MPTCP`
578 #[cfg(not(any(
579 windows,
580 target_os = "android",
581 target_os = "dragonfly",
582 target_os = "emscripten",
583 target_os = "freebsd",
584 target_os = "fuchsia",
585 target_os = "haiku",
586 target_os = "illumos",
587 target_os = "ios",
588 target_os = "macos",
589 target_os = "netbsd",
590 target_os = "openbsd",
591 target_os = "solaris",
592 )))]
593 pub const MPTCP: Self = Self(c::IPPROTO_MPTCP as _);
594 /// `IPPROTO_FRAGMENT`
595 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
596 pub const FRAGMENT: Self = Self(c::IPPROTO_FRAGMENT as _);
597 /// `IPPROTO_ICMPV6`
598 pub const ICMPV6: Self = Self(c::IPPROTO_ICMPV6 as _);
599 /// `IPPROTO_MH`
600 #[cfg(not(any(
601 windows,
602 target_os = "dragonfly",
603 target_os = "haiku",
604 target_os = "illumos",
605 target_os = "ios",
606 target_os = "macos",
607 target_os = "netbsd",
608 target_os = "openbsd",
609 target_os = "solaris",
610 )))]
611 pub const MH: Self = Self(c::IPPROTO_MH as _);
612 /// `IPPROTO_ROUTING`
613 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
614 pub const ROUTING: Self = Self(c::IPPROTO_ROUTING as _);
615
616 /// Constructs a `Protocol` from a raw integer.
617 #[inline]
618 pub const fn from_raw(raw: RawProtocol) -> Self {
619 Self(raw)
620 }
621
622 /// Returns the raw integer for this `Protocol`.
623 #[inline]
624 pub const fn as_raw(self) -> RawProtocol {
625 self.0
626 }
627 }
628
629 /// `SHUT_*` constants for use with [`shutdown`].
630 ///
631 /// [`shutdown`]: crate::net::shutdown
632 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
633 #[repr(i32)]
634 pub enum Shutdown {
635 /// `SHUT_RD`—Disable further read operations.
636 Read = c::SHUT_RD,
637 /// `SHUT_WR`—Disable further write operations.
638 Write = c::SHUT_WR,
639 /// `SHUT_RDWR`—Disable further read and write operations.
640 ReadWrite = c::SHUT_RDWR,
641 }
642
643 bitflags! {
644 /// `SOCK_*` constants for use with [`accept_with`] and [`acceptfrom_with`].
645 ///
646 /// [`accept_with`]: crate::net::accept_with
647 /// [`acceptfrom_with`]: crate::net::acceptfrom_with
648 pub struct AcceptFlags: c::c_int {
649 /// `SOCK_NONBLOCK`
650 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
651 const NONBLOCK = c::SOCK_NONBLOCK;
652
653 /// `SOCK_CLOEXEC`
654 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
655 const CLOEXEC = c::SOCK_CLOEXEC;
656 }
657 }
658
659 bitflags! {
660 /// `SOCK_*` constants for use with [`socket`].
661 ///
662 /// [`socket`]: crate::net::socket
663 pub struct SocketFlags: c::c_int {
664 /// `SOCK_NONBLOCK`
665 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
666 const NONBLOCK = c::SOCK_NONBLOCK;
667
668 /// `SOCK_CLOEXEC`
669 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
670 const CLOEXEC = c::SOCK_CLOEXEC;
671 }
672 }
673
674 /// Timeout identifier for use with [`set_socket_timeout`] and
675 /// [`get_socket_timeout`].
676 ///
677 /// [`set_socket_timeout`]: crate::net::sockopt::set_socket_timeout.
678 /// [`get_socket_timeout`]: crate::net::sockopt::get_socket_timeout.
679 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
680 #[repr(i32)]
681 pub enum Timeout {
682 /// `SO_RCVTIMEO`—Timeout for receiving.
683 Recv = c::SO_RCVTIMEO,
684
685 /// `SO_SNDTIMEO`—Timeout for sending.
686 Send = c::SO_SNDTIMEO,
687 }