1use std::fmt;
2use std::pin::Pin;
3
4use crate::io::{self, BufRead, Read};
5use crate::task::{Context, Poll};
6
7pub fn empty() -> Empty {
26 Empty { _private: () }
27}
28
29pub struct Empty {
36 _private: (),
37}
38
39impl fmt::Debug for Empty {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 f.pad("Empty { .. }")
42 }
43}
44
45impl Read for Empty {
46 #[inline]
47 fn poll_read(
48 self: Pin<&mut Self>,
49 _: &mut Context<'_>,
50 _: &mut [u8],
51 ) -> Poll<io::Result<usize>> {
52 Poll::Ready(Ok(0))
53 }
54}
55
56impl BufRead for Empty {
57 #[inline]
58 fn poll_fill_buf<'a>(
59 self: Pin<&'a mut Self>,
60 _: &mut Context<'_>,
61 ) -> Poll<io::Result<&'a [u8]>> {
62 Poll::Ready(Ok(&[]))
63 }
64
65 #[inline]
66 fn consume(self: Pin<&mut Self>, _: usize) {}
67}