1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::io::AsyncRead;
use futures_core::future::Future;
use futures_core::task::{LocalWaker, Poll};
use std::io;
use std::marker::Unpin;
use std::pin::Pin;
#[derive(Debug)]
pub struct Read<'a, R: ?Sized + 'a> {
reader: &'a mut R,
buf: &'a mut [u8],
}
impl<R: ?Sized> Unpin for Read<'_, R> {}
impl<'a, R: AsyncRead + ?Sized> Read<'a, R> {
pub(super) fn new(reader: &'a mut R, buf: &'a mut [u8]) -> Self {
Read { reader, buf }
}
}
impl<R: AsyncRead + ?Sized> Future for Read<'_, R> {
type Output = io::Result<usize>;
fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
let this = &mut *self;
this.reader.poll_read(lw, this.buf)
}
}