Skip to main content

rbdc/
rt.rs

1#[cfg(feature = "tls-native-tls")]
2pub use native_tls;
3use std::future::Future;
4
5pub use tokio::{
6    self, fs, io::AsyncRead, io::AsyncReadExt, io::AsyncWrite, io::AsyncWriteExt, io::ReadBuf,
7    net::TcpStream, runtime::Handle, task::spawn, task::yield_now, time::sleep, time::timeout,
8};
9
10pub fn block_on<T, R>(task: T) -> R
11where
12    T: Future<Output = R> + Send + 'static,
13    T::Output: Send + 'static,
14{
15    tokio::task::block_in_place(|| {
16        tokio::runtime::Builder::new_multi_thread()
17            .enable_all()
18            .build()
19            .expect("tokio block_on fail")
20            .block_on(task)
21    })
22}
23
24//unix
25#[cfg(unix)]
26pub use tokio::net::UnixStream;
27
28#[cfg(feature = "tls-native-tls")]
29pub use tokio_native_tls::{TlsConnector, TlsStream};
30
31#[cfg(feature = "tls-rustls")]
32pub use tokio_rustls::{TlsConnector, client::TlsStream};