1use std::io;
2
3use {Poll, Future, Async, task};
4
5use futures_io::AsyncWrite;
6
7#[derive(Debug)]
16pub struct Close<A> {
17 a: Option<A>,
18}
19
20pub fn close<A>(a: A) -> Close<A>
21 where A: AsyncWrite,
22{
23 Close {
24 a: Some(a),
25 }
26}
27
28impl<A> Future for Close<A>
29 where A: AsyncWrite,
30{
31 type Item = A;
32 type Error = io::Error;
33
34 fn poll(&mut self, cx: &mut task::Context) -> Poll<A, io::Error> {
35 try_ready!(self.a.as_mut().unwrap().poll_close(cx));
36 Ok(Async::Ready(self.a.take().unwrap()))
37 }
38}