1use crate::io::AsyncRead;
2use futures_core::future::Future;
3use futures_core::task::{Context, Poll};
4use std::io::{self, IoSliceMut};
5use std::pin::Pin;
6
7/// Future for the [`read_vectored`](super::AsyncReadExt::read_vectored) method.
8#[derive(Debug)]
9#[must_use = "futures do nothing unless you `.await` or poll them"]
10pub struct ReadVectored<'a, R: ?Sized> {
11 reader: &'a mut R,
12 bufs: &'a mut [IoSliceMut<'a>],
13}
14
15impl<R: ?Sized + Unpin> Unpin for ReadVectored<'_, R> {}
16
17impl<'a, R: AsyncRead + ?Sized + Unpin> ReadVectored<'a, R> {
18 pub(super) fn new(reader: &'a mut R, bufs: &'a mut [IoSliceMut<'a>]) -> Self {
19 Self { reader, bufs }
20 }
21}
22
23impl<R: AsyncRead + ?Sized + Unpin> Future for ReadVectored<'_, R> {
24 type Output = io::Result<usize>;
25
26 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
27 let this: &mut ReadVectored<'_, R> = &mut *self;
28 Pin::new(&mut this.reader).poll_read_vectored(cx, this.bufs)
29 }
30}
31