1use std::future::Future;
2use std::io;
3use std::os::fd::RawFd;
4
5use crate::Fd;
6use crate::addr::SockAddr;
7
8pub trait RecvMsgPacket {
9 fn msg_mut_ptr(&mut self) -> *mut libc::msghdr;
10}
11
12pub trait SendMsgPacket {
13 fn msg_ptr(&mut self) -> *const libc::msghdr;
14}
15
16pub trait SubmitOps: Sized {
17 fn submit_accept(self, fd: Fd)
18 -> impl Future<Output = io::Result<(RawFd, SockAddr)>> + 'static;
19
20 fn submit_read<B>(self, fd: Fd, buf: B) -> impl Future<Output = (io::Result<u32>, B)> + 'static
21 where
22 B: AsMut<[u8]> + Unpin + 'static;
23
24 fn submit_send_raw<B>(
25 self,
26 fd: Fd,
27 buf: B,
28 len: usize,
29 ) -> impl Future<Output = (io::Result<u32>, B)> + 'static
30 where
31 B: AsRef<[u8]> + Unpin + 'static;
32
33 fn submit_sendmsg_raw<P>(
34 self,
35 fd: Fd,
36 packet: P,
37 ) -> impl Future<Output = (io::Result<u32>, P)> + 'static
38 where
39 P: SendMsgPacket + Unpin + 'static;
40
41 fn submit_recvmsg_raw<P>(
42 self,
43 fd: Fd,
44 packet: P,
45 ) -> impl Future<Output = (io::Result<u32>, P)> + 'static
46 where
47 P: RecvMsgPacket + Unpin + 'static;
48}