]>
git.proxmox.com Git - rustc.git/blob - vendor/rustix-0.36.5/src/backend/linux_raw/io/types.rs
2 use bitflags
::bitflags
;
3 use core
::marker
::PhantomData
;
6 /// `FD_*` constants for use with [`fcntl_getfd`] and [`fcntl_setfd`].
8 /// [`fcntl_getfd`]: crate::io::fcntl_getfd
9 /// [`fcntl_setfd`]: crate::io::fcntl_setfd
10 pub struct FdFlags
: c
::c_uint
{
12 const CLOEXEC
= linux_raw_sys
::general
::FD_CLOEXEC
;
17 /// `RWF_*` constants for use with [`preadv2`] and [`pwritev2`].
19 /// [`preadv2`]: crate::io::preadv2
20 /// [`pwritev2`]: crate::io::pwritev
21 pub struct ReadWriteFlags
: c
::c_uint
{
22 /// `RWF_DSYNC` (since Linux 4.7)
23 const DSYNC
= linux_raw_sys
::general
::RWF_DSYNC
;
24 /// `RWF_HIPRI` (since Linux 4.6)
25 const HIPRI
= linux_raw_sys
::general
::RWF_HIPRI
;
26 /// `RWF_SYNC` (since Linux 4.7)
27 const SYNC
= linux_raw_sys
::general
::RWF_SYNC
;
28 /// `RWF_NOWAIT` (since Linux 4.14)
29 const NOWAIT
= linux_raw_sys
::general
::RWF_NOWAIT
;
30 /// `RWF_APPEND` (since Linux 4.16)
31 const APPEND
= linux_raw_sys
::general
::RWF_APPEND
;
35 #[cfg(any(target_os = "android", target_os = "linux"))]
37 /// `SPLICE_F_*` constants for use with [`splice`] and [`vmsplice`].
38 pub struct SpliceFlags
: c
::c_uint
{
40 const MOVE
= linux_raw_sys
::general
::SPLICE_F_MOVE
;
41 /// `SPLICE_F_NONBLOCK`
42 const NONBLOCK
= linux_raw_sys
::general
::SPLICE_F_NONBLOCK
;
44 const MORE
= linux_raw_sys
::general
::SPLICE_F_MORE
;
46 const GIFT
= linux_raw_sys
::general
::SPLICE_F_GIFT
;
51 /// `O_*` constants for use with [`dup2`].
53 /// [`dup2`]: crate::io::dup2
54 pub struct DupFlags
: c
::c_uint
{
56 const CLOEXEC
= linux_raw_sys
::general
::O_CLOEXEC
;
61 /// `O_*` constants for use with [`pipe_with`].
63 /// [`pipe_with`]: crate::io::pipe_with
64 pub struct PipeFlags
: c
::c_uint
{
66 const CLOEXEC
= linux_raw_sys
::general
::O_CLOEXEC
;
68 const DIRECT
= linux_raw_sys
::general
::O_DIRECT
;
70 const NONBLOCK
= linux_raw_sys
::general
::O_NONBLOCK
;
75 /// `EFD_*` flags for use with [`eventfd`].
77 /// [`eventfd`]: crate::io::eventfd
78 pub struct EventfdFlags
: c
::c_uint
{
80 const CLOEXEC
= linux_raw_sys
::general
::EFD_CLOEXEC
;
82 const NONBLOCK
= linux_raw_sys
::general
::EFD_NONBLOCK
;
84 const SEMAPHORE
= linux_raw_sys
::general
::EFD_SEMAPHORE
;
88 /// `PIPE_BUF`—The maximum size of a write to a pipe guaranteed to be atomic.
89 pub const PIPE_BUF
: usize = linux_raw_sys
::general
::PIPE_BUF
as usize;
91 pub(crate) const AT_FDCWD
: c
::c_int
= linux_raw_sys
::general
::AT_FDCWD
;
92 pub(crate) const STDIN_FILENO
: c
::c_uint
= linux_raw_sys
::general
::STDIN_FILENO
;
93 pub(crate) const STDOUT_FILENO
: c
::c_uint
= linux_raw_sys
::general
::STDOUT_FILENO
;
94 pub(crate) const STDERR_FILENO
: c
::c_uint
= linux_raw_sys
::general
::STDERR_FILENO
;
96 /// A buffer type used with `vmsplice`.
97 /// It is guaranteed to be ABI compatible with the iovec type on Unix platforms and WSABUF on Windows.
98 /// Unlike `IoSlice` and `IoSliceMut` it is semantically like a raw pointer,
99 /// and therefore can be shared or mutated as needed.
101 pub struct IoSliceRaw
<'a
> {
103 _lifetime
: PhantomData
<&'
a ()>,
106 impl<'a
> IoSliceRaw
<'a
> {
107 /// Creates a new IoSlice wrapping a byte slice.
108 pub fn from_slice(buf
: &'a
[u8]) -> Self {
111 iov_base
: buf
.as_ptr() as *mut u8 as *mut c
::c_void
,
112 iov_len
: buf
.len() as _
,
114 _lifetime
: PhantomData
,
118 /// Creates a new IoSlice wrapping a mutable byte slice.
119 pub fn from_slice_mut(buf
: &'a
mut [u8]) -> Self {
122 iov_base
: buf
.as_mut_ptr() as *mut c
::c_void
,
123 iov_len
: buf
.len() as _
,
125 _lifetime
: PhantomData
,