moirai_async/io/
traits.rs1use std::io;
2use std::pin::Pin;
3use std::task::{Context, Poll};
4
5pub trait AsyncRead {
7 fn poll_read(
9 self: Pin<&mut Self>,
10 cx: &mut Context<'_>,
11 buf: &mut [u8],
12 ) -> Poll<io::Result<usize>>;
13}
14
15pub trait AsyncWrite {
17 fn poll_write(
19 self: Pin<&mut Self>,
20 cx: &mut Context<'_>,
21 buf: &[u8],
22 ) -> Poll<io::Result<usize>>;
23
24 fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>;
26
27 fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>>;
29}
30
31pub trait AsyncBufRead: AsyncRead {
33 fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&[u8]>>;
36
37 fn consume(self: Pin<&mut Self>, amt: usize);
39}