async_std/io/read/
read.rs

1use std::pin::Pin;
2use std::future::Future;
3
4use crate::io::{self, Read};
5use crate::task::{Context, Poll};
6
7#[doc(hidden)]
8#[allow(missing_debug_implementations)]
9pub struct ReadFuture<'a, T: Unpin + ?Sized> {
10    pub(crate) reader: &'a mut T,
11    pub(crate) buf: &'a mut [u8],
12}
13
14impl<T: Read + Unpin + ?Sized> Future for ReadFuture<'_, T> {
15    type Output = io::Result<usize>;
16
17    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
18        let Self { reader, buf } = &mut *self;
19        Pin::new(reader).poll_read(cx, buf)
20    }
21}