embedded_platform/io/
shutdown.rs1use core::future;
2use core::pin;
3use core::task;
4
5#[derive(Debug)]
6#[must_use = "futures do nothing unless you `.await` or poll them"]
7pub struct Shutdown<'a, A: ?Sized> {
8 writer: &'a mut A,
9}
10
11pub(crate) fn shutdown<A>(writer: &mut A) -> Shutdown<A>
12where
13 A: super::Write + Unpin + ?Sized,
14{
15 Shutdown { writer }
16}
17
18impl<A> future::Future for Shutdown<'_, A>
19where
20 A: super::Write + Unpin + ?Sized,
21{
22 type Output = Result<(), A::Error>;
23
24 fn poll(mut self: pin::Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
25 let this = &mut *self;
26 pin::Pin::new(&mut *this.writer).poll_shutdown(cx)
27 }
28}