ringolo/future/lib/
types.rs

1use bitflags::bitflags;
2
3/// Specifies the address family (domain) used for socket communication.
4///
5/// This corresponds to the `domain` argument in `socket(2)`.
6///
7/// # References
8///
9/// [address_families(7)](https://man7.org/linux/man-pages/man7/address_families.7.html)
10#[repr(i32)]
11#[non_exhaustive]
12#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
13pub enum AddressFamily {
14    /// Local communication (see [`unix(7)`](https://man7.org/linux/man-pages/man7/unix.7.html))
15    Unix = libc::AF_UNIX,
16    /// IPv4 Internet protocols (see [`ip(7)`](https://man7.org/linux/man-pages/man7/ip.7.html))
17    Inet = libc::AF_INET,
18    /// IPv6 Internet protocols (see [`ipv6(7)`](https://man7.org/linux/man-pages/man7/ipv6.7.html))
19    Inet6 = libc::AF_INET6,
20    /// Kernel interface for interacting with the routing table
21    Route = libc::PF_ROUTE,
22    /// IPX - Novell protocols
23    Ipx = libc::AF_IPX,
24    /// AppleTalk
25    AppleTalk = libc::AF_APPLETALK,
26    /// IBM SNA
27    Sna = libc::AF_SNA,
28    /// InfiniBand native addressing
29    #[cfg(all(target_os = "linux", not(target_env = "uclibc")))]
30    Ib = libc::AF_IB,
31    /// Multiprotocol Label Switching
32    #[cfg(all(target_os = "linux", not(target_env = "uclibc")))]
33    Mpls = libc::AF_MPLS,
34    /// Bluetooth low-level socket protocol
35    Bluetooth = libc::AF_BLUETOOTH,
36    /// New "modular ISDN" driver interface protocol
37    Isdn = libc::AF_ISDN,
38    /// Near field communication
39    Nfc = libc::AF_NFC,
40}
41bitflags! {
42    /// `AT_*` constants for use with [`LinkAt`], and other `*at` ops.
43    ///
44    /// [`LinkAt`]: crate::future::lib::ops::LinkAt
45    #[repr(transparent)]
46    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
47    pub struct AtFlags: libc::c_int {
48        /// Do not dereference symbolic links; operate on the link itself.
49        const SYMLINK_NOFOLLOW = libc::AT_SYMLINK_NOFOLLOW;
50
51        /// Perform access checks using the effective user and group IDs.
52        const EACCESS = libc::AT_EACCESS;
53
54        /// Remove a directory instead of a file (equivalent to `rmdir`).
55        const REMOVEDIR = libc::AT_REMOVEDIR;
56
57        /// Follow symbolic links if the path is a link.
58        const SYMLINK_FOLLOW = libc::AT_SYMLINK_FOLLOW;
59
60        /// Suppress automounting if the path refers to an automount point.
61        const NO_AUTOMOUNT = libc::AT_NO_AUTOMOUNT;
62
63        /// Operate on the file descriptor directly if the path is an empty string.
64        const EMPTY_PATH = libc::AT_EMPTY_PATH;
65
66        /// Synchronize with the filesystem based on the default `stat()` behavior.
67        const STATX_SYNC_AS_STAT = libc::AT_STATX_SYNC_AS_STAT;
68
69        /// Force synchronization with the backing storage or server to ensure fresh data.
70        const STATX_FORCE_SYNC = libc::AT_STATX_FORCE_SYNC;
71
72        /// Do not synchronize; accept cached attributes if they are available.
73        const STATX_DONT_SYNC = libc::AT_STATX_DONT_SYNC;
74
75        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
76        const _ = !0;
77    }
78}
79
80/// Represents an event returned by `epoll_wait`.
81///
82/// This structure encapsulates the events that occurred and the user data
83/// associated with the file descriptor.
84#[derive(Clone, Copy, Debug)]
85#[repr(transparent)]
86pub struct EpollEvent {
87    event: libc::epoll_event,
88}
89
90impl EpollEvent {
91    /// Creates a new `EpollEvent` with the specified flags and user data.
92    pub fn new(events: EpollFlags, data: u64) -> Self {
93        EpollEvent {
94            event: libc::epoll_event {
95                events: events.bits() as u32,
96                u64: data,
97            },
98        }
99    }
100
101    /// Creates an empty `EpollEvent` initialized to zero.
102    pub fn empty() -> Self {
103        unsafe { std::mem::zeroed::<EpollEvent>() }
104    }
105
106    /// Returns the `EpollFlags` associated with this event.
107    pub fn events(&self) -> EpollFlags {
108        EpollFlags::from_bits(self.event.events as libc::c_int).unwrap()
109    }
110
111    /// Returns the user data associated with this event.
112    pub fn data(&self) -> u64 {
113        self.event.u64
114    }
115}
116
117bitflags!(
118    /// Available flags for epoll family of syscalls. See [`epoll_ctl man page`]
119    /// for the complete description of all these flags. For completion, we list
120    /// legacy flags inherited from [`poll`] as well.
121    ///
122    /// [`epoll_ctl man page`]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html
123    /// [`poll`]: https://man7.org/linux/man-pages/man2/poll.2.html
124    #[repr(transparent)]
125    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
126    pub struct EpollFlags: libc::c_int {
127        /// The associated file is available for read(2) operations.
128        const EPOLLIN = libc::EPOLLIN;
129
130        /// There is an exceptional condition on the file descriptor.
131        /// See the discussion of POLLPRI in poll(2).
132        const EPOLLPRI = libc::EPOLLPRI;
133
134        /// The associated file is available for write(2) operations.
135        const EPOLLOUT = libc::EPOLLOUT;
136
137        /// Error condition happened on the associated file descriptor.
138        const EPOLLERR = libc::EPOLLERR;
139
140        /// Hang up happened on the associated file descriptor.
141        const EPOLLHUP = libc::EPOLLHUP;
142
143        /// Stream socket peer closed connection, or shut down writing
144        /// half of connection.
145        const EPOLLRDHUP = libc::EPOLLRDHUP;
146
147        /// Sets an exclusive wakeup mode for the epoll file descriptor
148        /// that is being attached to the target file descriptor, fd.
149        const EPOLLEXCLUSIVE = libc::EPOLLEXCLUSIVE;
150
151        /// If `EPOLLONESHOT` and `EPOLLET` are clear and the process has
152        /// the `CAP_BLOCK_SUSPEND` capability, ensure that the system
153        /// does not enter "suspend" or "hibernate" while this event is
154        /// pending or being processed.
155        const EPOLLWAKEUP = libc::EPOLLWAKEUP;
156
157        /// Requests one-shot notification for the associated file
158        /// descriptor.
159        const EPOLLONESHOT = libc::EPOLLONESHOT;
160
161        /// Requests edge-triggered notification for the associated
162        /// file descriptor.
163        const EPOLLET = libc::EPOLLET;
164
165        /// [Legacy] Equivalent to EPOLLIN.
166        const EPOLLRDNORM = libc::EPOLLRDNORM;
167
168        /// [Legacy] Priority band data can be read (generally unused on Linux).
169        const EPOLLRDBAND = libc::EPOLLRDBAND;
170
171        /// [Legacy] Equivalent to EPOLLOUT.
172        const EPOLLWRNORM = libc::EPOLLWRNORM;
173
174        /// [Legacy] Priority data may be written.
175        const EPOLLWRBAND = libc::EPOLLWRBAND;
176
177        /// [Legacy] Unused.
178        const EPOLLMSG = libc::EPOLLMSG;
179
180        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
181        const _ = !0;
182    }
183);
184
185/// Valid operations for the [`epoll_ctl`](https://man7.org/linux/man-pages/man2/epoll_ctl.2.html) system call.
186#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
187#[repr(i32)]
188#[non_exhaustive]
189pub enum EpollOp {
190    /// Register the target file descriptor on the epoll instance.
191    EpollCtlAdd = libc::EPOLL_CTL_ADD,
192    /// Deregister the target file descriptor from the epoll instance.
193    EpollCtlDel = libc::EPOLL_CTL_DEL,
194    /// Change the event event associated with the target file descriptor.
195    EpollCtlMod = libc::EPOLL_CTL_MOD,
196}
197
198bitflags!(
199    /// Mode argument flags for fallocate determining operation performed on a given range.
200    #[repr(transparent)]
201    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
202    pub struct FallocateFlags: libc::c_int {
203        /// File size is not changed.
204        ///
205        /// offset + len can be greater than file size.
206        const FALLOC_FL_KEEP_SIZE = libc::FALLOC_FL_KEEP_SIZE;
207
208        /// Deallocates space by creating a hole.
209        ///
210        /// Must be ORed with FALLOC_FL_KEEP_SIZE. Byte range starts at offset and continues for len bytes.
211        const FALLOC_FL_PUNCH_HOLE = libc::FALLOC_FL_PUNCH_HOLE;
212
213        /// Removes byte range from a file without leaving a hole.
214        ///
215        /// Byte range to collapse starts at offset and continues for len bytes.
216        const FALLOC_FL_COLLAPSE_RANGE = libc::FALLOC_FL_COLLAPSE_RANGE;
217
218        /// Zeroes space in specified byte range.
219        ///
220        /// Byte range starts at offset and continues for len bytes.
221        const FALLOC_FL_ZERO_RANGE = libc::FALLOC_FL_ZERO_RANGE;
222
223        /// Increases file space by inserting a hole within the file size.
224        ///
225        /// Does not overwrite existing data. Hole starts at offset and continues for len bytes.
226        const FALLOC_FL_INSERT_RANGE = libc::FALLOC_FL_INSERT_RANGE;
227
228        /// Shared file data extants are made private to the file.
229        ///
230        /// Guarantees that a subsequent write will not fail due to lack of space.
231        const FALLOC_FL_UNSHARE_RANGE = libc::FALLOC_FL_UNSHARE_RANGE;
232
233        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
234        const _ = !0;
235    }
236);
237
238/// Wrapper around `futex_waitv` as used in [`futex_waitv` system
239/// call](https://www.kernel.org/doc/html/latest/userspace-api/futex2.html).
240#[derive(Default, Debug, Clone, Copy)]
241#[repr(transparent)]
242pub struct FutexWaiter(io_uring::types::FutexWaitV);
243
244impl FutexWaiter {
245    /// Creates a new, empty `FutexWaiter`.
246    pub fn new() -> Self {
247        Self(io_uring::types::FutexWaitV::new())
248    }
249
250    /// Sets the expected value of the futex.
251    ///
252    /// The kernel will atomically verify that the value at `uaddr` matches this `val`.
253    /// If they do not match, the wait operation will fail immediately with `EAGAIN`.
254    pub fn val(mut self, val: u64) -> Self {
255        self.0 = self.0.val(val);
256        self
257    }
258
259    /// Sets the user address (pointer) of the futex variable to monitor.
260    ///
261    /// This should be the virtual address of the integer in memory.
262    pub fn uaddr(mut self, uaddr: u64) -> Self {
263        self.0 = self.0.uaddr(uaddr);
264        self
265    }
266
267    /// Configures the flags for this specific futex waiter.
268    ///
269    /// These flags determine the size of the futex variable (8, 16, 32, or 64 bits)
270    /// and whether it is process-private or shared.
271    pub fn flags(mut self, flags: Futex2Flags) -> Self {
272        self.0 = self.0.flags(flags.bits());
273        self
274    }
275}
276
277bitflags! {
278    /// `FUTEX2_*` flags for use with [`FutexWait`]
279    ///
280    /// Not to be confused with [`WaitvFlags`], which is passed as an argument
281    /// to the `waitv` function.
282    ///
283    /// [`FutexWait`]: crate::future::lib::ops::FutexWait
284    #[repr(transparent)]
285    #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
286    pub struct Futex2Flags: u32 {
287        /// `FUTEX_U8`
288        const SIZE_U8 = linux_raw_sys::general::FUTEX2_SIZE_U8;
289        /// `FUTEX_U16`
290        const SIZE_U16 = linux_raw_sys::general::FUTEX2_SIZE_U16;
291        /// `FUTEX_U32`
292        const SIZE_U32 = linux_raw_sys::general::FUTEX2_SIZE_U32;
293        /// `FUTEX_U64`
294        const SIZE_U64 = linux_raw_sys::general::FUTEX2_SIZE_U64;
295        /// `FUTEX_SIZE_MASK`
296        const SIZE_MASK = linux_raw_sys::general::FUTEX2_SIZE_MASK;
297
298        /// `FUTEX2_NUMA`
299        const NUMA = linux_raw_sys::general::FUTEX2_NUMA;
300
301        /// `FUTEX2_PRIVATE`
302        const PRIVATE = linux_raw_sys::general::FUTEX2_PRIVATE;
303
304        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
305        const _ = !0;
306    }
307}
308
309impl Default for Futex2Flags {
310    fn default() -> Self {
311        Self::empty()
312    }
313}
314
315bitflags! {
316    /// "File mode / permissions" flags.
317    #[repr(transparent)]
318    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
319    pub struct Mode: libc::mode_t {
320        /// Read, write and execute for owner.
321        const S_IRWXU = libc::S_IRWXU;
322
323        /// Read for owner.
324        const S_IRUSR = libc::S_IRUSR;
325
326        /// Write for owner.
327        const S_IWUSR = libc::S_IWUSR;
328
329        /// Execute for owner.
330        const S_IXUSR = libc::S_IXUSR;
331
332        /// Read write and execute for group.
333        const S_IRWXG = libc::S_IRWXG;
334
335        /// Read for group.
336        const S_IRGRP = libc::S_IRGRP;
337
338        /// Write for group.
339        const S_IWGRP = libc::S_IWGRP;
340
341        /// Execute for group.
342        const S_IXGRP = libc::S_IXGRP;
343
344        /// Read, write and execute for other.
345        const S_IRWXO = libc::S_IRWXO;
346
347        /// Read for other.
348        const S_IROTH = libc::S_IROTH;
349
350        /// Write for other.
351        const S_IWOTH = libc::S_IWOTH;
352
353        /// Execute for other.
354        const S_IXOTH = libc::S_IXOTH;
355
356        /// Set user id on execution.
357        const S_ISUID = libc::S_ISUID;
358
359        /// Set group id on execution.
360        const S_ISGID = libc::S_ISGID;
361
362        /// Sticky bit.
363        ///
364        /// When applied to a directory, it restricts file deletion to the file owner,
365        /// the directory owner, or the superuser.
366        const S_ISVTX = libc::S_ISVTX;
367
368        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
369        const _ = !0;
370    }
371}
372
373bitflags!(
374    /// Configuration options for opened files.
375    #[repr(transparent)]
376    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
377    pub struct OFlag: libc::c_int {
378        /// Mask for the access mode of the file.
379        const O_ACCMODE = libc::O_ACCMODE;
380
381        /// Open the file in append-only mode.
382        const O_APPEND = libc::O_APPEND;
383
384        /// Generate a signal when input or output becomes possible.
385        const O_ASYNC = libc::O_ASYNC;
386
387        /// Closes the file descriptor once an `execve` call is made.
388        ///
389        /// Also sets the file offset to the beginning of the file.
390        const O_CLOEXEC = libc::O_CLOEXEC;
391
392        /// Create the file if it does not exist.
393        const O_CREAT = libc::O_CREAT;
394
395        /// Try to minimize cache effects of the I/O for this file.
396        const O_DIRECT = libc::O_DIRECT;
397
398        /// If the specified path isn't a directory, fail.
399        const O_DIRECTORY = libc::O_DIRECTORY;
400
401        /// Implicitly follow each `write()` with an `fdatasync()`.
402        const O_DSYNC = libc::O_DSYNC;
403
404        /// Error out if a file was not created.
405        const O_EXCL = libc::O_EXCL;
406
407        /// Same as `O_SYNC`.
408        const O_FSYNC = libc::O_FSYNC;
409
410        /// Allow files whose sizes can't be represented in an `off_t` to be opened.
411        const O_LARGEFILE = libc::O_LARGEFILE;
412
413        /// Do not update the file last access time during `read(2)`s.
414        const O_NOATIME = libc::O_NOATIME;
415
416        /// Don't attach the device as the process' controlling terminal.
417        const O_NOCTTY = libc::O_NOCTTY;
418
419        /// Same as `O_NONBLOCK`.
420        const O_NDELAY = libc::O_NDELAY;
421
422        /// `open()` will fail if the given path is a symbolic link.
423        const O_NOFOLLOW = libc::O_NOFOLLOW;
424
425        /// When possible, open the file in nonblocking mode.
426        const O_NONBLOCK = libc::O_NONBLOCK;
427
428        /// Obtain a file descriptor for low-level access.
429        ///
430        /// The file itself is not opened and other file operations will fail.
431        const O_PATH = libc::O_PATH;
432
433        /// Only allow reading.
434        ///
435        /// This should not be combined with `O_WRONLY` or `O_RDWR`.
436        const O_RDONLY = libc::O_RDONLY;
437
438        /// Allow both reading and writing.
439        ///
440        /// This should not be combined with `O_WRONLY` or `O_RDONLY`.
441        const O_RDWR = libc::O_RDWR;
442
443        /// Similar to `O_DSYNC` but applies to `read`s instead.
444        const O_RSYNC = libc::O_RSYNC;
445
446        /// Implicitly follow each `write()` with an `fsync()`.
447        const O_SYNC = libc::O_SYNC;
448
449        /// Create an unnamed temporary file.
450        const O_TMPFILE = libc::O_TMPFILE;
451
452        /// Truncate an existing regular file to 0 length if it allows writing.
453        const O_TRUNC = libc::O_TRUNC;
454
455        /// Only allow writing.
456        ///
457        /// This should not be combined with `O_RDONLY` or `O_RDWR`.
458        const O_WRONLY = libc::O_WRONLY;
459
460        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
461        const _ = !0;
462    }
463);
464
465/// Wrapper for the OpenHow struct.
466//
467// The reason we can't use the `nix::fcntl::OpenHow` is field access is private,
468// so we can't do the transformation to `io_uring::types::OpenHow`.
469#[derive(Debug)]
470#[repr(transparent)]
471pub struct OpenHow(io_uring::types::OpenHow);
472
473impl Default for OpenHow {
474    fn default() -> Self {
475        Self::new()
476    }
477}
478
479impl OpenHow {
480    /// Creates a new `OpenHow` with empty flags, mode, and resolve.
481    pub fn new() -> Self {
482        Self(io_uring::types::OpenHow::new())
483    }
484
485    /// Sets the `OFlag` for the `OpenHow` structure.
486    pub fn with_flags(mut self, flags: OFlag) -> Self {
487        self.0 = self.0.flags(flags.bits() as libc::c_ulonglong);
488        self
489    }
490
491    /// Sets the `Mode` for the `OpenHow` structure.
492    pub fn with_mode(mut self, mode: Mode) -> Self {
493        self.0 = self.0.mode(mode.bits() as libc::c_ulonglong);
494        self
495    }
496
497    /// Sets the `ResolveFlag` for the `OpenHow` structure.
498    pub fn with_resolve(mut self, resolve: ResolveFlag) -> Self {
499        self.0 = self.0.resolve(resolve.bits());
500        self
501    }
502}
503
504/// The specific advice provided to [`posix_fadvise`](https://man7.org/linux/man-pages/man2/posix_fadvise.2.html).
505#[repr(i32)]
506#[non_exhaustive]
507#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
508pub enum PosixFadviseAdvice {
509    /// Revert to the default data access behavior.
510    Normal,
511
512    /// The file data will be accessed sequentially.
513    Sequential,
514
515    /// A hint that file data will be accessed randomly, and prefetching is likely not
516    /// advantageous.
517    Random,
518
519    /// The specified data will only be accessed once and then not reused.
520    NoReuse,
521
522    /// The specified data will be accessed in the near future.
523    WillNeed,
524
525    /// The specified data will not be accessed in the near future.
526    DontNeed,
527}
528
529bitflags! {
530    /// Path resolution flags.
531    ///
532    /// See [path resolution(7)](https://man7.org/linux/man-pages/man7/path_resolution.7.html)
533    /// for details of the resolution process.
534    #[repr(transparent)]
535    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
536    pub struct ResolveFlag: libc::c_ulonglong {
537        /// Do not permit the path resolution to succeed if any component of
538        /// the resolution is not a descendant of the directory indicated by
539        /// dirfd.  This causes absolute symbolic links (and absolute values of
540        /// pathname) to be rejected.
541        const RESOLVE_BENEATH = libc::RESOLVE_BENEATH;
542
543        /// Treat the directory referred to by dirfd as the root directory
544        /// while resolving pathname.
545        const RESOLVE_IN_ROOT = libc::RESOLVE_IN_ROOT;
546
547        /// Disallow all magic-link resolution during path resolution. Magic
548        /// links are symbolic link-like objects that are most notably found
549        /// in proc(5);  examples include `/proc/[pid]/exe` and `/proc/[pid]/fd/*`.
550        ///
551        /// See symlink(7) for more details.
552        const RESOLVE_NO_MAGICLINKS = libc::RESOLVE_NO_MAGICLINKS;
553
554        /// Disallow resolution of symbolic links during path resolution. This
555        /// option implies RESOLVE_NO_MAGICLINKS.
556        const RESOLVE_NO_SYMLINKS = libc::RESOLVE_NO_SYMLINKS;
557
558        /// Disallow traversal of mount points during path resolution (including
559        /// all bind mounts).
560        const RESOLVE_NO_XDEV = libc::RESOLVE_NO_XDEV;
561
562        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
563        const _ = !0;
564    }
565}
566
567bitflags! {
568    /// Additional socket options
569    #[repr(transparent)]
570    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
571    pub struct SockFlag: libc::c_int {
572        /// Set non-blocking mode on the new socket
573        const SOCK_NONBLOCK = libc::SOCK_NONBLOCK;
574
575        /// Set close-on-exec on the new descriptor
576        const SOCK_CLOEXEC = libc::SOCK_CLOEXEC;
577
578        /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
579        const _ = !0;
580    }
581}
582
583/// Specifies the specific protocol to be used with the socket.
584///
585/// This corresponds to the `protocol` argument in [`socket(2)`](https://man7.org/linux/man-pages/man2/socket.2.html).
586#[repr(i32)]
587#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
588#[non_exhaustive]
589pub enum SockProtocol {
590    /// TCP protocol ([ip(7)](https://man7.org/linux/man-pages/man7/ip.7.html))
591    Tcp = libc::IPPROTO_TCP,
592    /// UDP protocol ([ip(7)](https://man7.org/linux/man-pages/man7/ip.7.html))
593    Udp = libc::IPPROTO_UDP,
594    /// Raw sockets ([raw(7)](https://man7.org/linux/man-pages/man7/raw.7.html))
595    Raw = libc::IPPROTO_RAW,
596    /// Packet filter on loopback traffic
597    EthLoop = (libc::ETH_P_LOOP as u16).to_be() as i32,
598    /// ICMP protocol ([icmp(7)](https://man7.org/linux/man-pages/man7/icmp.7.html))
599    Icmp = libc::IPPROTO_ICMP,
600    /// ICMPv6 protocol (ICMP over IPv6)
601    IcmpV6 = libc::IPPROTO_ICMPV6,
602}
603
604/// Specifies the communication semantics (socket type).
605///
606/// This corresponds to the `type` argument in [`socket(2)`](https://man7.org/linux/man-pages/man2/socket.2.html).
607#[derive(Clone, Copy, PartialEq, Eq, Debug)]
608#[repr(i32)]
609#[non_exhaustive]
610pub enum SockType {
611    /// Provides sequenced, reliable, two-way, connection-
612    /// based byte streams.  An out-of-band data transmission
613    /// mechanism may be supported.
614    Stream = libc::SOCK_STREAM,
615    /// Supports datagrams (connectionless, unreliable
616    /// messages of a fixed maximum length).
617    Datagram = libc::SOCK_DGRAM,
618    /// Provides a sequenced, reliable, two-way connection-
619    /// based data transmission path for datagrams of fixed
620    /// maximum length; a consumer is required to read an
621    /// entire packet with each input system call.
622    SeqPacket = libc::SOCK_SEQPACKET,
623    /// Provides raw network protocol access.
624    Raw = libc::SOCK_RAW,
625    /// Provides a reliable datagram layer that does not
626    /// guarantee ordering.
627    Rdm = libc::SOCK_RDM,
628}