1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Mock APIs for `futures 0.3` traits

/// Mock APIs for `futures::io` traits
#[cfg(feature = "mock-futures-io-0-3")]
pub mod io {
    use core::pin::Pin;
    use core::task::{Context, Poll};
    use std::io::{IoSlice, IoSliceMut};

    use futures_io_0_3::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, Error, SeekFrom};

    use crate::unimock;

    #[unimock(prefix=crate, api=AsyncBufReadMock, mirror=AsyncBufRead)]
    pub trait AsyncBufRead {
        fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8], Error>>;
        fn consume(self: Pin<&mut Self>, amt: usize);
    }

    #[unimock(prefix=crate, api=AsyncReadMock, mirror=AsyncRead)]
    pub trait AsyncRead {
        fn poll_read(
            self: Pin<&mut Self>,
            cx: &mut Context<'_>,
            buf: &mut [u8],
        ) -> Poll<Result<usize, Error>>;

        // Provided method
        fn poll_read_vectored(
            self: Pin<&mut Self>,
            cx: &mut Context<'_>,
            bufs: &mut [IoSliceMut<'_>],
        ) -> Poll<Result<usize, Error>> {
        }
    }

    #[unimock(prefix=crate, api=AsyncSeekMock, mirror=AsyncSeek)]
    pub trait AsyncSeek {
        fn poll_seek(
            self: Pin<&mut Self>,
            cx: &mut Context<'_>,
            pos: SeekFrom,
        ) -> Poll<Result<u64, Error>>;
    }

    #[unimock(prefix=crate, api=AsyncWriteMock, mirror=AsyncWrite)]
    pub trait AsyncWrite {
        // Required methods
        fn poll_write(
            self: Pin<&mut Self>,
            cx: &mut Context<'_>,
            buf: &[u8],
        ) -> Poll<Result<usize, Error>>;
        fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>;
        fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>>;

        // Provided method
        fn poll_write_vectored(
            self: Pin<&mut Self>,
            cx: &mut Context<'_>,
            bufs: &[IoSlice<'_>],
        ) -> Poll<Result<usize, Error>> {
        }
    }
}