forked from compio-rs/compio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathop.rs
More file actions
756 lines (669 loc) · 20.4 KB
/
op.rs
File metadata and controls
756 lines (669 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
//! The async operations.
//!
//! Types in this mod represents the low-level operations passed to kernel.
//! The operation itself doesn't perform anything.
//! You need to pass them to [`crate::Proactor`], and poll the driver.
use std::{io, marker::PhantomPinned, mem::ManuallyDrop, net::Shutdown};
use compio_buf::{BufResult, IntoInner, IoBuf, IoBufMut, IoVectoredBuf, SetLen};
use pin_project_lite::pin_project;
use socket2::{SockAddr, SockAddrStorage, socklen_t};
pub use crate::sys::op::{
Accept, Recv, RecvFrom, RecvFromVectored, RecvMsg, RecvVectored, Send, SendMsg, SendTo,
SendToVectored, SendVectored,
};
#[cfg(windows)]
pub use crate::sys::op::{ConnectNamedPipe, DeviceIoControl};
#[cfg(unix)]
pub use crate::sys::op::{
CreateDir, CreateSocket, CurrentDir, FileStat, HardLink, Interest, OpenFile, PathStat,
PollOnce, ReadVectored, ReadVectoredAt, Rename, Stat, Symlink, TruncateFile, Unlink,
WriteVectored, WriteVectoredAt,
};
#[cfg(io_uring)]
pub use crate::sys::op::{
ReadManaged, ReadManagedAt, ReadMulti, ReadMultiAt, RecvFromManaged, RecvManaged, RecvMulti,
};
#[cfg(linux_all)]
pub use crate::sys::op::{SendMsgZc, SendToVectoredZc, SendToZc, SendVectoredZc, SendZc, Splice};
use crate::{Extra, OwnedFd, SharedFd, TakeBuffer, sys::aio::*};
/// Trait to update the buffer length inside the [`BufResult`].
pub trait BufResultExt {
/// Call [`SetLen::advance_to`] if the result is [`Ok`].
///
/// # Safety
///
/// The result value must be a valid length to advance to.
unsafe fn map_advanced(self) -> Self;
}
/// Trait to update the buffer length inside the [`BufResult`].
pub trait VecBufResultExt {
/// Call [`SetLen::advance_vec_to`] if the result is [`Ok`].
///
/// # Safety
///
/// The result value must be a valid length to advance to.
unsafe fn map_vec_advanced(self) -> Self;
}
impl<T: SetLen + IoBuf> BufResultExt for BufResult<usize, T> {
unsafe fn map_advanced(self) -> Self {
unsafe {
self.map_res(|res| (res, ()))
.map_advanced()
.map_res(|(res, _)| res)
}
}
}
impl<T: SetLen + IoVectoredBuf> VecBufResultExt for BufResult<usize, T> {
unsafe fn map_vec_advanced(self) -> Self {
unsafe {
self.map_res(|res| (res, ()))
.map_vec_advanced()
.map_res(|(res, _)| res)
}
}
}
impl<T: SetLen + IoBuf, O> BufResultExt for BufResult<(usize, O), T> {
unsafe fn map_advanced(self) -> Self {
self.map(|(init, obj), mut buffer| {
unsafe {
buffer.advance_to(init);
}
((init, obj), buffer)
})
}
}
impl<T: SetLen + IoVectoredBuf, O> VecBufResultExt for BufResult<(usize, O), T> {
unsafe fn map_vec_advanced(self) -> Self {
self.map(|(init, obj), mut buffer| {
unsafe {
buffer.advance_vec_to(init);
}
((init, obj), buffer)
})
}
}
impl<T: SetLen + IoBuf, C: SetLen + IoBuf, O> BufResultExt
for BufResult<(usize, usize, O), (T, C)>
{
unsafe fn map_advanced(self) -> Self {
self.map(
|(init_buffer, init_control, obj), (mut buffer, mut control)| {
unsafe {
buffer.advance_to(init_buffer);
control.advance_to(init_control);
}
((init_buffer, init_control, obj), (buffer, control))
},
)
}
}
impl<T: SetLen + IoVectoredBuf, C: SetLen + IoBuf, O> VecBufResultExt
for BufResult<(usize, usize, O), (T, C)>
{
unsafe fn map_vec_advanced(self) -> Self {
self.map(
|(init_buffer, init_control, obj), (mut buffer, mut control)| {
unsafe {
buffer.advance_vec_to(init_buffer);
control.advance_to(init_control);
}
((init_buffer, init_control, obj), (buffer, control))
},
)
}
}
/// Helper trait for [`RecvFrom`], [`RecvFromVectored`] and [`RecvMsg`].
pub trait RecvResultExt {
/// The mapped result.
type RecvResult;
/// Create [`SockAddr`] if the result is [`Ok`].
fn map_addr(self) -> Self::RecvResult;
}
impl<T> RecvResultExt for BufResult<usize, (T, SockAddrStorage, socklen_t)> {
type RecvResult = BufResult<(usize, Option<SockAddr>), T>;
fn map_addr(self) -> Self::RecvResult {
self.map_buffer(|(buffer, addr_buffer, addr_size)| (buffer, addr_buffer, addr_size, 0))
.map_addr()
.map_res(|(res, _, addr)| (res, addr))
}
}
impl<T> RecvResultExt for BufResult<usize, (T, SockAddrStorage, socklen_t, usize)> {
type RecvResult = BufResult<(usize, usize, Option<SockAddr>), T>;
fn map_addr(self) -> Self::RecvResult {
self.map2(
|res, (buffer, addr_buffer, addr_size, len)| {
let addr =
(addr_size > 0).then(|| unsafe { SockAddr::new(addr_buffer, addr_size) });
((res, len, addr), buffer)
},
|(buffer, ..)| buffer,
)
}
}
/// Helper trait for [`ReadManagedAt`] and [`RecvManaged`].
pub trait ResultTakeBuffer {
/// The buffer pool of the op.
type BufferPool;
/// The buffer type of the op.
type Buffer<'a>;
/// Take the buffer from result.
fn take_buffer(self, pool: &Self::BufferPool) -> io::Result<Self::Buffer<'_>>;
}
impl<T: TakeBuffer> ResultTakeBuffer for (BufResult<usize, T>, Extra) {
type Buffer<'a> = T::Buffer<'a>;
type BufferPool = T::BufferPool;
fn take_buffer(self, pool: &Self::BufferPool) -> io::Result<Self::Buffer<'_>> {
let (BufResult(result, op), extra) = self;
op.take_buffer(pool, result, extra.buffer_id()?)
}
}
impl ResultTakeBuffer for BufResult<usize, Extra> {
type Buffer<'a> = crate::BorrowedBuffer<'a>;
type BufferPool = crate::BufferPool;
fn take_buffer(self, pool: &Self::BufferPool) -> io::Result<Self::Buffer<'_>> {
#[cfg(io_uring)]
{
let BufResult(result, extra) = self;
crate::sys::take_buffer(pool, result, extra.buffer_id()?)
}
#[cfg(not(io_uring))]
{
let _pool = pool;
unreachable!("take_buffer should not be called for non-io-uring ops")
}
}
}
pin_project! {
/// Spawn a blocking function in the thread pool.
pub struct Asyncify<F, D> {
pub(crate) f: Option<F>,
pub(crate) data: Option<D>,
_p: PhantomPinned,
}
}
impl<F, D> Asyncify<F, D> {
/// Create [`Asyncify`].
pub fn new(f: F) -> Self {
Self {
f: Some(f),
data: None,
_p: PhantomPinned,
}
}
}
impl<F, D> IntoInner for Asyncify<F, D> {
type Inner = D;
fn into_inner(mut self) -> Self::Inner {
self.data.take().expect("the data should not be None")
}
}
pin_project! {
/// Spawn a blocking function with a file descriptor in the thread pool.
pub struct AsyncifyFd<S, F, D> {
pub(crate) fd: SharedFd<S>,
pub(crate) f: Option<F>,
pub(crate) data: Option<D>,
_p: PhantomPinned,
}
}
impl<S, F, D> AsyncifyFd<S, F, D> {
/// Create [`AsyncifyFd`].
pub fn new(fd: SharedFd<S>, f: F) -> Self {
Self {
fd,
f: Some(f),
data: None,
_p: PhantomPinned,
}
}
}
impl<S, F, D> IntoInner for AsyncifyFd<S, F, D> {
type Inner = D;
fn into_inner(mut self) -> Self::Inner {
self.data.take().expect("the data should not be None")
}
}
pin_project! {
/// Spawn a blocking function with two file descriptors in the thread pool.
pub struct AsyncifyFd2<S1, S2, F, D> {
pub(crate) fd1: SharedFd<S1>,
pub(crate) fd2: SharedFd<S2>,
pub(crate) f: Option<F>,
pub(crate) data: Option<D>,
_p: PhantomPinned,
}
}
impl<S1, S2, F, D> AsyncifyFd2<S1, S2, F, D> {
/// Create [`AsyncifyFd2`].
pub fn new(fd1: SharedFd<S1>, fd2: SharedFd<S2>, f: F) -> Self {
Self {
fd1,
fd2,
f: Some(f),
data: None,
_p: PhantomPinned,
}
}
}
impl<S1, S2, F, D> IntoInner for AsyncifyFd2<S1, S2, F, D> {
type Inner = D;
fn into_inner(mut self) -> Self::Inner {
self.data.take().expect("the data should not be None")
}
}
/// Close the file fd.
pub struct CloseFile {
pub(crate) fd: ManuallyDrop<OwnedFd>,
}
impl CloseFile {
/// Create [`CloseFile`].
pub fn new(fd: OwnedFd) -> Self {
Self {
fd: ManuallyDrop::new(fd),
}
}
}
pin_project! {
/// Read a file at specified position into specified buffer.
#[derive(Debug)]
pub struct ReadAt<T: IoBufMut, S> {
pub(crate) fd: S,
pub(crate) offset: u64,
#[pin]
pub(crate) buffer: T,
pub(crate) aiocb: aiocb,
_p: PhantomPinned,
}
}
impl<T: IoBufMut, S> ReadAt<T, S> {
/// Create [`ReadAt`].
pub fn new(fd: S, offset: u64, buffer: T) -> Self {
Self {
fd,
offset,
buffer,
aiocb: new_aiocb(),
_p: PhantomPinned,
}
}
}
impl<T: IoBufMut, S> IntoInner for ReadAt<T, S> {
type Inner = T;
fn into_inner(self) -> Self::Inner {
self.buffer
}
}
pin_project! {
/// Write a file at specified position from specified buffer.
#[derive(Debug)]
pub struct WriteAt<T: IoBuf, S> {
pub(crate) fd: S,
pub(crate) offset: u64,
#[pin]
pub(crate) buffer: T,
pub(crate) aiocb: aiocb,
_p: PhantomPinned,
}
}
impl<T: IoBuf, S> WriteAt<T, S> {
/// Create [`WriteAt`].
pub fn new(fd: S, offset: u64, buffer: T) -> Self {
Self {
fd,
offset,
buffer,
aiocb: new_aiocb(),
_p: PhantomPinned,
}
}
}
impl<T: IoBuf, S> IntoInner for WriteAt<T, S> {
type Inner = T;
fn into_inner(self) -> Self::Inner {
self.buffer
}
}
pin_project! {
/// Read a file.
pub struct Read<T: IoBufMut, S> {
pub(crate) fd: S,
#[pin]
pub(crate) buffer: T,
_p: PhantomPinned,
}
}
impl<T: IoBufMut, S> Read<T, S> {
/// Create [`Read`].
pub fn new(fd: S, buffer: T) -> Self {
Self {
fd,
buffer,
_p: PhantomPinned,
}
}
}
impl<T: IoBufMut, S> IntoInner for Read<T, S> {
type Inner = T;
fn into_inner(self) -> Self::Inner {
self.buffer
}
}
/// Write a file.
pub struct Write<T: IoBuf, S> {
pub(crate) fd: S,
pub(crate) buffer: T,
_p: PhantomPinned,
}
impl<T: IoBuf, S> Write<T, S> {
/// Create [`Write`].
pub fn new(fd: S, buffer: T) -> Self {
Self {
fd,
buffer,
_p: PhantomPinned,
}
}
}
impl<T: IoBuf, S> IntoInner for Write<T, S> {
type Inner = T;
fn into_inner(self) -> Self::Inner {
self.buffer
}
}
pin_project! {
/// Sync data to the disk.
pub struct Sync<S> {
pub(crate) fd: S,
pub(crate) datasync: bool,
pub(crate) aiocb: aiocb,
}
}
impl<S> Sync<S> {
/// Create [`Sync`].
///
/// If `datasync` is `true`, the file metadata may not be synchronized.
pub fn new(fd: S, datasync: bool) -> Self {
Self {
fd,
datasync,
aiocb: new_aiocb(),
}
}
}
/// Shutdown a socket.
pub struct ShutdownSocket<S> {
pub(crate) fd: S,
pub(crate) how: Shutdown,
}
impl<S> ShutdownSocket<S> {
/// Create [`ShutdownSocket`].
pub fn new(fd: S, how: Shutdown) -> Self {
Self { fd, how }
}
}
/// Close socket fd.
pub struct CloseSocket {
pub(crate) fd: ManuallyDrop<OwnedFd>,
}
impl CloseSocket {
/// Create [`CloseSocket`].
pub fn new(fd: OwnedFd) -> Self {
Self {
fd: ManuallyDrop::new(fd),
}
}
}
/// Connect to a remote address.
pub struct Connect<S> {
pub(crate) fd: S,
pub(crate) addr: SockAddr,
}
impl<S> Connect<S> {
/// Create [`Connect`]. `fd` should be bound.
pub fn new(fd: S, addr: SockAddr) -> Self {
Self { fd, addr }
}
}
#[cfg(any(not(io_uring), fusion))]
pub(crate) mod managed {
use std::io;
use compio_buf::IntoInner;
use pin_project_lite::pin_project;
use socket2::SockAddr;
use super::{Read, ReadAt, Recv, RecvFrom};
use crate::{AsFd, BorrowedBuffer, BufferPool, FallbackOwnedBuffer, TakeBuffer};
fn take_buffer(
slice: FallbackOwnedBuffer,
buffer_pool: &BufferPool,
result: io::Result<usize>,
) -> io::Result<BorrowedBuffer<'_>> {
let result = result?;
#[cfg(fusion)]
let buffer_pool = buffer_pool.as_poll();
// SAFETY: result is valid
let res = unsafe { buffer_pool.create_proxy(slice, result) };
#[cfg(fusion)]
let res = BorrowedBuffer::new_poll(res);
Ok(res)
}
pin_project! {
/// Read a file at specified position into managed buffer.
pub struct ReadManagedAt<S> {
#[pin]
pub(crate) op: ReadAt<FallbackOwnedBuffer, S>,
}
}
impl<S> ReadManagedAt<S> {
/// Create [`ReadManagedAt`].
pub fn new(fd: S, offset: u64, pool: &BufferPool, len: usize) -> io::Result<Self> {
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: ReadAt::new(fd, offset, pool.get_buffer(len)?),
})
}
}
impl<S> TakeBuffer for ReadManagedAt<S> {
type Buffer<'a> = BorrowedBuffer<'a>;
type BufferPool = BufferPool;
fn take_buffer(
self,
buffer_pool: &BufferPool,
result: io::Result<usize>,
_: u16,
) -> io::Result<BorrowedBuffer<'_>> {
take_buffer(self.op.into_inner(), buffer_pool, result)
}
}
pin_project! {
/// Read a file into managed buffer.
pub struct ReadManaged<S> {
#[pin]
pub(crate) op: Read<FallbackOwnedBuffer, S>,
}
}
impl<S> ReadManaged<S> {
/// Create [`ReadManaged`].
pub fn new(fd: S, pool: &BufferPool, len: usize) -> io::Result<Self> {
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: Read::new(fd, pool.get_buffer(len)?),
})
}
}
impl<S> TakeBuffer for ReadManaged<S> {
type Buffer<'a> = BorrowedBuffer<'a>;
type BufferPool = BufferPool;
fn take_buffer(
self,
buffer_pool: &Self::BufferPool,
result: io::Result<usize>,
_: u16,
) -> io::Result<Self::Buffer<'_>> {
take_buffer(self.op.into_inner(), buffer_pool, result)
}
}
pin_project! {
/// Receive data from remote into managed buffer.
///
/// It is only used for socket operations. If you want to read from a pipe,
/// use [`ReadManaged`].
pub struct RecvManaged<S> {
#[pin]
pub(crate) op: Recv<FallbackOwnedBuffer, S>,
}
}
impl<S> RecvManaged<S> {
/// Create [`RecvManaged`].
pub fn new(fd: S, pool: &BufferPool, len: usize, flags: i32) -> io::Result<Self> {
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: Recv::new(fd, pool.get_buffer(len)?, flags),
})
}
}
impl<S> TakeBuffer for RecvManaged<S> {
type Buffer<'a> = BorrowedBuffer<'a>;
type BufferPool = BufferPool;
fn take_buffer(
self,
buffer_pool: &Self::BufferPool,
result: io::Result<usize>,
_: u16,
) -> io::Result<Self::Buffer<'_>> {
take_buffer(self.op.into_inner(), buffer_pool, result)
}
}
pin_project! {
/// Receive data and source address into managed buffer.
pub struct RecvFromManaged<S: AsFd> {
#[pin]
pub(crate) op: RecvFrom<FallbackOwnedBuffer, S>,
}
}
impl<S: AsFd> RecvFromManaged<S> {
/// Create [`RecvFromManaged`].
pub fn new(fd: S, pool: &BufferPool, len: usize, flags: i32) -> io::Result<Self> {
#[cfg(fusion)]
let pool = pool.as_poll();
Ok(Self {
op: RecvFrom::new(fd, pool.get_buffer(len)?, flags),
})
}
}
impl<S: AsFd> TakeBuffer for RecvFromManaged<S> {
type Buffer<'a> = (BorrowedBuffer<'a>, Option<SockAddr>);
type BufferPool = BufferPool;
fn take_buffer(
self,
buffer_pool: &Self::BufferPool,
result: io::Result<usize>,
_: u16,
) -> io::Result<Self::Buffer<'_>> {
let result = result?;
#[cfg(fusion)]
let buffer_pool = buffer_pool.as_poll();
let (slice, addr_buffer, addr_size) = self.op.into_inner();
let addr = (addr_size > 0).then(|| unsafe { SockAddr::new(addr_buffer, addr_size) });
// SAFETY: result is valid
let res = unsafe { buffer_pool.create_proxy(slice, result) };
#[cfg(fusion)]
let res = BorrowedBuffer::new_poll(res);
Ok((res, addr))
}
}
/// Read a file at specified position into multiple managed buffers.
pub type ReadMultiAt<S> = ReadManagedAt<S>;
/// Read a file into multiple managed buffers.
pub type ReadMulti<S> = ReadManaged<S>;
/// Receive data from remote into multiple managed buffers.
pub type RecvMulti<S> = RecvManaged<S>;
}
#[cfg(not(io_uring))]
pub use managed::*;
bitflags::bitflags! {
/// Flags for operations.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct OpCodeFlag: u32 {
/// Detect `Read` OpCode
const Read = 1 << 0;
/// Detect `Readv` OpCode
const Readv = 1 << 1;
/// Detect `Write` OpCode
const Write = 1 << 2;
/// Detect `Writev` OpCode
const Writev = 1 << 3;
/// Detect `Fsync` OpCode
const Fsync = 1 << 4;
/// Detect `Accept` OpCode
const Accept = 1 << 5;
/// Detect `Connect` OpCode
const Connect = 1 << 6;
/// Detect `Recv` OpCode
const Recv = 1 << 7;
/// Detect `Send` OpCode
const Send = 1 << 8;
/// Detect `RecvMsg` OpCode
const RecvMsg = 1 << 9;
/// Detect `SendMsg` OpCode
const SendMsg = 1 << 10;
/// Detect `AsyncCancel` OpCode
const AsyncCancel = 1 << 11;
/// Detect `OpenAt` OpCode
const OpenAt = 1 << 12;
/// Detect `Close` OpCode
const Close = 1 << 13;
/// Detect `Splice` OpCode
const Splice = 1 << 14;
/// Detect `Shutdown` OpCode
const Shutdown = 1 << 15;
/// Detect `PollAdd` OpCode
const PollAdd = 1 << 16;
}
}
impl OpCodeFlag {
/// Get the [`OpCodeFlag`] corresponds to basic OpCodes that are commonly
/// used.
pub fn basic() -> Self {
OpCodeFlag::Read
| OpCodeFlag::Readv
| OpCodeFlag::Write
| OpCodeFlag::Writev
| OpCodeFlag::Fsync
| OpCodeFlag::Accept
| OpCodeFlag::Connect
| OpCodeFlag::Recv
| OpCodeFlag::Send
| OpCodeFlag::RecvMsg
| OpCodeFlag::SendMsg
| OpCodeFlag::PollAdd
}
}
#[cfg(io_uring)]
impl OpCodeFlag {
pub(crate) fn get_codes(self) -> impl Iterator<Item = u8> {
use io_uring::opcode::*;
self.iter().map(|flag| match flag {
OpCodeFlag::Read => Read::CODE,
OpCodeFlag::Readv => Readv::CODE,
OpCodeFlag::Write => Write::CODE,
OpCodeFlag::Writev => Writev::CODE,
OpCodeFlag::Fsync => Fsync::CODE,
OpCodeFlag::Accept => Accept::CODE,
OpCodeFlag::Connect => Connect::CODE,
OpCodeFlag::Recv => Recv::CODE,
OpCodeFlag::Send => Send::CODE,
OpCodeFlag::RecvMsg => RecvMsg::CODE,
OpCodeFlag::SendMsg => SendMsg::CODE,
OpCodeFlag::AsyncCancel => AsyncCancel::CODE,
OpCodeFlag::OpenAt => OpenAt::CODE,
OpCodeFlag::Close => Close::CODE,
OpCodeFlag::Splice => Splice::CODE,
OpCodeFlag::Shutdown => Shutdown::CODE,
OpCodeFlag::PollAdd => PollAdd::CODE,
unknown => unreachable!("Unknown OpCodeFlag specified: {unknown:?}"),
})
}
}