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
use once_cell::sync::Lazy;
use crate::query::QueryDriver;
pub type Error = Box<dyn std::error::Error>;
pub type Result<T> = std::result::Result<T, Error>;
mod common;
mod database;
pub mod derives;
pub mod query;
pub mod test_attr;
#[cfg(feature = "migrate")]
pub mod migrate;
pub const FOSS_DRIVERS: &[QueryDriver] = &[
#[cfg(feature = "mysql")]
QueryDriver::new::<sqlx_mysql::MySql>(),
#[cfg(feature = "postgres")]
QueryDriver::new::<sqlx_postgres::Postgres>(),
#[cfg(feature = "sqlite")]
QueryDriver::new::<sqlx_sqlite::Sqlite>(),
];
pub fn block_on<F>(f: F) -> F::Output
where
F: std::future::Future,
{
#[cfg(feature = "_rt-tokio")]
{
use tokio::runtime::{self, Runtime};
static TOKIO_RT: Lazy<Runtime> = Lazy::new(|| {
runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to start Tokio runtime")
});
return TOKIO_RT.block_on(f);
}
#[cfg(all(feature = "_rt-async-std", not(feature = "tokio")))]
return async_std::task::block_on(f);
#[cfg(not(any(feature = "_rt-async-std", feature = "tokio")))]
sqlx_core::rt::missing_rt(f)
}