Replies: 2 comments
-
I'd like answering this question by asking several questions. Let's say we are using native operating system features to implement a async runtime. pub trait AsyncRead {
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> impl Unpin + Future<Output = io::Result<usize>>;
} How to use this signature to implement an async socket? |
Beta Was this translation helpful? Give feedback.
-
The main advantage of the current traits is that it's possible to read and write at the same time with the current design. It would have been impossible to implement |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just a general question about
AsyncRead
andAsyncWrite
.Given the usage, I'd imagine the trait would look something like
Which resembles std::io::Read and is easy to work with and implement. However, the real traits have a
poll_read
method, which is difficult to implement.For example, when trying to forward calls to
read
to a wrapper typeWhy are the
AsyncRead
andAsyncWrite
traits the way they are?Beta Was this translation helpful? Give feedback.
All reactions