Coverage Report

Created: 2025-06-24 06:17

/rust/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/io/read.rs
Line
Count
Source (jump to first uncovered line)
1
use crate::io::AsyncRead;
2
use futures_core::future::Future;
3
use futures_core::task::{Context, Poll};
4
use std::io;
5
use std::pin::Pin;
6
7
/// Future for the [`read`](super::AsyncReadExt::read) method.
8
#[derive(Debug)]
9
#[must_use = "futures do nothing unless you `.await` or poll them"]
10
pub struct Read<'a, R: ?Sized> {
11
    reader: &'a mut R,
12
    buf: &'a mut [u8],
13
}
14
15
impl<R: ?Sized + Unpin> Unpin for Read<'_, R> {}
16
17
impl<'a, R: AsyncRead + ?Sized + Unpin> Read<'a, R> {
18
0
    pub(super) fn new(reader: &'a mut R, buf: &'a mut [u8]) -> Self {
19
0
        Self { reader, buf }
20
0
    }
21
}
22
23
impl<R: AsyncRead + ?Sized + Unpin> Future for Read<'_, R> {
24
    type Output = io::Result<usize>;
25
26
0
    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
27
0
        let this = &mut *self;
28
0
        Pin::new(&mut this.reader).poll_read(cx, this.buf)
29
0
    }
30
}