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