Repository navigation
Expand file tree
/
Copy pathruntime.rs
More file actions
64 lines (56 loc) · 1.88 KB
/
Copy pathruntime.rs
File metadata and controls
64 lines (56 loc) · 1.88 KB
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
//
// We would like to see a generalized runtime type parameter that is defaulted on types.
// Something like:
//
// ```rust
// PgPool::new("postgres://...") // defaults to async-std
// PgPool::new_with("postgres://...", Tokio) // here is Tokio
// ```
//
// We also do not have the time to invest in bringing the community together on that. We have
// confidence that _something_ will emerge over the year. When such a time comes, the following
// egregious hack should be ruthlessly purged.
//
#[cfg(not(any(
feature = "runtime-actix",
feature = "runtime-async-std",
feature = "runtime-tokio",
)))]
compile_error!(
"one of 'runtime-actix', 'runtime-async-std' or 'runtime-tokio' features must be enabled"
);
#[cfg(any(
all(feature = "runtime-actix", feature = "runtime-async-std"),
all(feature = "runtime-actix", feature = "runtime-tokio"),
all(feature = "runtime-async-std", feature = "runtime-tokio"),
))]
compile_error!(
"only one of 'runtime-actix', 'runtime-async-std' or 'runtime-tokio' features must be enabled"
);
#[cfg(feature = "runtime-async-std")]
pub(crate) use async_std::{
self, fs,
future::timeout,
io::prelude::ReadExt as AsyncReadExt,
io::prelude::WriteExt as AsyncWriteExt,
io::{Read as AsyncRead, Write as AsyncWrite},
net::TcpStream,
task::sleep,
task::spawn,
};
#[cfg(all(feature = "runtime-async-std", unix))]
pub(crate) use async_std::os::unix::net::UnixStream;
#[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))]
pub(crate) use tokio::{
fs,
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
net::TcpStream,
time::delay_for as sleep,
time::timeout,
};
#[cfg(feature = "runtime-tokio")]
pub use tokio::task::spawn;
#[cfg(feature = "runtime-actix")]
pub use actix_rt::spawn;
#[cfg(all(any(feature = "runtime-tokio", feature = "runtime-actix"), unix))]
pub use tokio::net::UnixStream;