async_rs/util/
dummy.rs

1use futures_core::Stream;
2use futures_io::{AsyncRead, AsyncWrite};
3use std::{
4    io,
5    marker::PhantomData,
6    pin::Pin,
7    task::{Context, Poll},
8};
9
10/// A dummy struct implementing Async IO traits
11#[derive(Debug)]
12pub struct DummyIO;
13
14impl AsyncRead for DummyIO {
15    fn poll_read(
16        self: Pin<&mut Self>,
17        _cx: &mut Context<'_>,
18        _buf: &mut [u8],
19    ) -> Poll<io::Result<usize>> {
20        Poll::Pending
21    }
22}
23
24impl AsyncWrite for DummyIO {
25    fn poll_write(
26        self: Pin<&mut Self>,
27        _cx: &mut Context<'_>,
28        _buf: &[u8],
29    ) -> Poll<io::Result<usize>> {
30        Poll::Pending
31    }
32
33    fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
34        Poll::Pending
35    }
36
37    fn poll_close(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
38        Poll::Pending
39    }
40}
41
42/// A dummy struct implementing Stream
43#[derive(Debug)]
44pub struct DummyStream<T>(pub PhantomData<T>);
45
46impl<T> Stream for DummyStream<T> {
47    type Item = T;
48
49    fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
50        Poll::Pending
51    }
52}