• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 [`close`](super::AsyncWriteExt::close) method.
8 #[derive(Debug)]
9 #[must_use = "futures do nothing unless you `.await` or poll them"]
10 pub struct Close<'a, W: ?Sized> {
11     writer: &'a mut W,
12 }
13 
14 impl<W: ?Sized + Unpin> Unpin for Close<'_, W> {}
15 
16 impl<'a, W: AsyncWrite + ?Sized + Unpin> Close<'a, W> {
new(writer: &'a mut W) -> Self17     pub(super) fn new(writer: &'a mut W) -> Self {
18         Self { writer }
19     }
20 }
21 
22 impl<W: AsyncWrite + ?Sized + Unpin> Future for Close<'_, W> {
23     type Output = io::Result<()>;
24 
poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>25     fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
26         Pin::new(&mut *self.writer).poll_close(cx)
27     }
28 }
29