1use futures_core::task::{Context, Poll};
2use futures_io::{AsyncBufRead, AsyncRead};
3use std::fmt;
4use std::io;
5use std::pin::Pin;
6
7#[must_use = "readers do nothing unless polled"]
9pub struct Empty {
10    _priv: (),
11}
12
13pub fn empty() -> Empty {
32    Empty { _priv: () }
33}
34
35impl AsyncRead for Empty {
36    #[inline]
37    fn poll_read(
38        self: Pin<&mut Self>,
39        _: &mut Context<'_>,
40        _: &mut [u8],
41    ) -> Poll<io::Result<usize>> {
42        Poll::Ready(Ok(0))
43    }
44}
45
46impl AsyncBufRead for Empty {
47    #[inline]
48    fn poll_fill_buf(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<io::Result<&[u8]>> {
49        Poll::Ready(Ok(&[]))
50    }
51    #[inline]
52    fn consume(self: Pin<&mut Self>, _: usize) {}
53}
54
55impl fmt::Debug for Empty {
56    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57        f.pad("Empty { .. }")
58    }
59}