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
use crate::io::util::timeout::read_exact_timeout::{read_exact_timeout, ReadExactTimeout};
use std::time::Duration;
use tokio::io::AsyncRead;
use crate::io::{read_timeout, ReadTimeout};

pub trait AsyncReadTimeoutExt: AsyncRead {
    fn read_exact_timeout<'a>(
        &'a mut self,
        buf: &'a mut [u8],
        timeout: Duration,
    ) -> ReadExactTimeout<'a, Self>
    where
        Self: Unpin,
    {
        read_exact_timeout(self, buf, timeout)
    }

    fn read_timeout<'a>(
        &'a mut self,
        buf: &'a mut [u8],
        timeout: Duration,
    ) -> ReadTimeout<'a, Self>
        where
            Self: Unpin,
    {
        read_timeout(self, buf, timeout)
    }

    fn read_to_end_timeout<'a>(&'a mut self, _buf: &'a mut Vec<u8>, _timeout: Duration)
    where
        Self: Unpin,
    {
        todo!()
    }

    fn read_to_string_timeout<'a>(&'a mut self, _dst: &'a mut String, _timeout: Duration)
    where
        Self: Unpin,
    {
        todo!()
    }
}

impl<R: AsyncRead + ?Sized> AsyncReadTimeoutExt for R {}