Support async trait such as `tokio::io::AsyncRead`
iamazy opened this issue · comments
Hi, I hava try this crate but got some errors because tokio-uring
doesn't implement some async trait for tokio_uring::net::TcpStream
etc.
The one of the error messages is as follows:
error[E0277]: the trait bound `tokio_uring::net::TcpStream: tokio::io::AsyncRead` is not satisfied
--> src/connection.rs:276:66
|
276 | .map(|stream| tokio_util::codec::Framed::new(stream, codec))?;
| ------------------------------ ^^^^^^ the trait `tokio::io::AsyncRead` is not implemented for `tokio_uring::net::TcpStream`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `tokio::io::AsyncRead`:
&[u8]
&mut T
Box<T>
BufStream<RW>
DuplexStream
Pin<P>
std::io::Cursor<T>
tokio::fs::File
and 17 others
note: required by a bound in `tokio_util::codec::Framed::<T, U>::new`
Is there any plan to support these traits?
There are plans to support AsyncRead/Write via IORING_OP_POLL_ADD, which allows us to do readiness-based IO with io_uring, but those implementations wouldn't have the efficiency benefits of io_uring, and would perform about the same as using epoll.
Unfortunately, AsyncRead/Write are pretty strongly tied to the readiness-based model of epoll and kqueue, and aren't a good fit for io_uring. A set of owned buffer traits is probably needed instead.
Is the plan then to have a separate tokio-uring-util crate that provides codecs that work with tokio-uring?