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
pub mod io {

    #[cfg(feature = "runtime-async-std")]
    pub(crate) use async_std::io::{Read, Write};

    #[cfg(feature = "runtime-tokio")]
    pub(crate) use tokio::io::{
        AsyncBufRead as BufRead, AsyncRead as Read, AsyncWrite as Write, BufStream,
    };
}

pub mod time {
    #[cfg(feature = "runtime-async-std")]
    pub use async_std::task::sleep;
    #[cfg(feature = "runtime-async-std")]
    pub use std::time::{Duration, Instant};

    #[cfg(feature = "runtime-tokio")]
    pub use tokio::time::{sleep, Duration, Instant};
}

pub mod thread {
    #[cfg(feature = "runtime-async-std")]
    pub(crate) use async_std::{sync::RwLock, task::spawn};

    #[cfg(feature = "runtime-tokio")]
    pub(crate) use tokio::{sync::RwLock, task::spawn};
}

pub mod net {
    #[cfg(feature = "runtime-async-std")]
    pub(crate) use async_std::net::TcpStream;

    #[cfg(feature = "runtime-tokio")]
    pub(crate) use tokio::net::TcpStream;
}

#[cfg(feature = "runtime-async-std")]
pub(crate) use async_std::task::JoinHandle;

#[cfg(feature = "runtime-tokio")]
pub(crate) use tokio::task::JoinHandle;