Repository navigation
Expand file tree
/
Copy pathlib.rs
More file actions
78 lines (64 loc) · 2.31 KB
/
Copy pathlib.rs
File metadata and controls
78 lines (64 loc) · 2.31 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#[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"
);
pub use sqlx_rt_macros::{main, test};
pub use native_tls;
#[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))]
pub use tokio::{
self, fs, io::AsyncRead, io::AsyncReadExt, io::AsyncWrite, io::AsyncWriteExt, net::TcpStream,
task::yield_now,
};
#[cfg(feature = "runtime-tokio")]
#[macro_export]
macro_rules! blocking {
($($expr:tt)*) => {
$crate::tokio::task::block_in_place(move || { $($expr)* })
};
}
#[cfg(feature = "runtime-actix")]
pub use {actix_rt, actix_threadpool};
#[cfg(feature = "runtime-actix")]
#[macro_export]
macro_rules! blocking {
($($expr:tt)*) => {
$crate::actix_threadpool::run(move || { $($expr)* }).await.map_err(|err| match err {
$crate::actix_threadpool::BlockingError::Error(e) => e,
$crate::actix_threadpool::BlockingError::Canceled => panic!("{}", err)
})
};
}
#[cfg(all(unix, any(feature = "runtime-tokio", feature = "runtime-actix")))]
pub use tokio::net::UnixStream;
#[cfg(feature = "runtime-async-std")]
pub use async_std::{
self, fs, io::prelude::ReadExt as AsyncReadExt, io::prelude::WriteExt as AsyncWriteExt,
io::Read as AsyncRead, io::Write as AsyncWrite, net::TcpStream, task::spawn, task::yield_now,
};
#[cfg(feature = "runtime-async-std")]
#[macro_export]
macro_rules! blocking {
($($expr:tt)*) => {
$crate::async_std::task::spawn_blocking(move || { $($expr)* }).await
};
}
#[cfg(all(unix, feature = "runtime-async-std"))]
pub use async_std::os::unix::net::UnixStream;
#[cfg(feature = "async-native-tls")]
pub use async_native_tls::{Error as TlsError, TlsConnector, TlsStream};
#[cfg(feature = "tokio-native-tls")]
pub use tokio_native_tls::{TlsConnector, TlsStream};
#[cfg(feature = "tokio-native-tls")]
pub use native_tls::Error as TlsError;