diff --git a/.github/workflows/sqlx.yml b/.github/workflows/sqlx.yml index 33d3b295d7..e4892e2dac 100644 --- a/.github/workflows/sqlx.yml +++ b/.github/workflows/sqlx.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] steps: - uses: actions/checkout@v2 @@ -144,7 +144,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] needs: check steps: - uses: actions/checkout@v2 @@ -180,7 +180,7 @@ jobs: strategy: matrix: postgres: [12, 10, 9_6, 9_5] - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] needs: check steps: - uses: actions/checkout@v2 @@ -232,7 +232,7 @@ jobs: strategy: matrix: mysql: [8, 5_7, 5_6] - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] needs: check steps: - uses: actions/checkout@v2 @@ -275,7 +275,7 @@ jobs: strategy: matrix: mariadb: [10_5, 10_4, 10_3, 10_2, 10_1] - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] needs: check steps: - uses: actions/checkout@v2 @@ -319,7 +319,7 @@ jobs: strategy: matrix: mssql: [2019] - runtime: [async-std, tokio, actix] + runtime: [async-std-native-tls, tokio-native-tls, actix-native-tls] needs: check steps: - uses: actions/checkout@v2 diff --git a/Cargo.lock b/Cargo.lock index 7390714894..48f4efb680 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,15 +88,73 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.1.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee81ba99bee79f3c8ae114ae4baa7eaa326f63447cf2ec65e4393618b63f8770" +checksum = "59740d83946db6a5af71ae25ddf9562c2b176b2ca42cf99a455f09f4a220d6b9" dependencies = [ "concurrent-queue", "event-listener", "futures-core", ] +[[package]] +name = "async-executor" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d373d78ded7d0b3fa8039375718cde0aace493f2e34fb60f51cbf567562ca801" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "vec-arena", +] + +[[package]] +name = "async-global-executor" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fefeb39da249f4c33af940b779a56723ce45809ef5c54dad84bb538d4ffb6d9e" +dependencies = [ + "async-executor", + "async-io", + "futures-lite", + "num_cpus", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38628c78a34f111c5a6b98fc87dfc056cd1590b61afe748b145be4623c56d194" +dependencies = [ + "cfg-if", + "concurrent-queue", + "fastrand", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "socket2", + "vec-arena", + "waker-fn", + "wepoll-sys-stjepang", + "winapi 0.3.9", +] + +[[package]] +name = "async-mutex" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" +dependencies = [ + "event-listener", +] + [[package]] name = "async-native-tls" version = "0.3.3" @@ -109,19 +167,34 @@ dependencies = [ "url", ] +[[package]] +name = "async-rustls" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c238bd34d425674d8003b8d674cc04baf74e1b71802f3c62451e3bf86f2858ef" +dependencies = [ + "futures-lite", + "rustls", + "webpki", +] + [[package]] name = "async-std" -version = "1.6.2" +version = "1.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d68a33ebc8b57800847d00787307f84a562224a14db069b0acefe4c2abbf5d" +checksum = "a9fa76751505e8df1c7a77762f60486f60c71bbd9b8557f4da6ad47d083732ed" dependencies = [ "async-attributes", - "async-task", + "async-global-executor", + "async-io", + "async-mutex", + "blocking", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-timer", + "futures-lite", + "gloo-timers", "kv-log-macro", "log", "memchr", @@ -130,15 +203,14 @@ dependencies = [ "pin-project-lite", "pin-utils", "slab", - "smol", "wasm-bindgen-futures", ] [[package]] name = "async-task" -version = "3.0.0" +version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" +checksum = "8ab27c1aa62945039e44edaeee1dc23c74cc0c303dd5fe0fb462a184f1c3a518" [[package]] name = "async-trait" @@ -241,16 +313,16 @@ dependencies = [ [[package]] name = "blocking" -version = "0.4.7" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" +checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" dependencies = [ "async-channel", + "async-task", "atomic-waker", + "fastrand", "futures-lite", "once_cell", - "parking", - "waker-fn", ] [[package]] @@ -397,9 +469,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.1.2" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1582139bb74d97ef232c30bc236646017db06f13ee7cc01fa24c9e55640f86d4" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" dependencies = [ "cache-padded", ] @@ -666,15 +738,18 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.2.1" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829694371bd7bbc6aee17c4ff624aad8bf9f4dc06c6f9f6071eaa08c89530d10" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "fastrand" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36a9cb09840f81cd211e435d00a4e487edd263dc3c8ff815c32dd76ad668ebed" +checksum = "ca5faf057445ce5c9d4329e382b2ce7ca38550ef3b73a5348362d5f24e0c7fe3" +dependencies = [ + "instant", +] [[package]] name = "fnv" @@ -763,9 +838,9 @@ checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" [[package]] name = "futures-lite" -version = "0.1.9" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc8771bd1bb4c7be3c5f072a1d5e18086ef220f100a0a4efece41076e87b9f2" +checksum = "381a7ad57b1bad34693f63f6f377e1abded7a9c85c9d3eb6771e11c60aaadab9" dependencies = [ "fastrand", "futures-core", @@ -803,16 +878,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper", -] - [[package]] name = "futures-util" version = "0.3.5" @@ -1027,9 +1092,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.73" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] name = "libm" @@ -1290,9 +1355,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" [[package]] name = "oorandom" @@ -1357,9 +1422,9 @@ checksum = "06de47b848347d8c4c94219ad8ecd35eb90231704b067e67e6ae2e36ee023510" [[package]] name = "parking" -version = "1.0.6" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" @@ -1487,6 +1552,19 @@ dependencies = [ "web-sys", ] +[[package]] +name = "polling" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0720e0b9ea9d52451cf29d3413ba8a9303f8815d9d9653ef70e03ff73e65566" +dependencies = [ + "cfg-if", + "libc", + "log", + "wepoll-sys-stjepang", + "winapi 0.3.9", +] + [[package]] name = "ppv-lite86" version = "0.2.8" @@ -1675,6 +1753,21 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ring" +version = "0.16.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.9", +] + [[package]] name = "rsa" version = "0.3.0" @@ -1716,6 +1809,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d1126dcf58e93cee7d098dbda643b5f92ed724f1f6a63007c1116eed6700c81" +dependencies = [ + "base64 0.12.3", + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1741,18 +1847,22 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "scoped-tls" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" - [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "0.4.4" @@ -1792,12 +1902,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" version = "1.0.114" @@ -1905,27 +2009,6 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" -[[package]] -name = "smol" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" -dependencies = [ - "async-task", - "blocking", - "concurrent-queue", - "fastrand", - "futures-io", - "futures-util", - "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2", - "wepoll-sys-stjepang", - "winapi 0.3.9", -] - [[package]] name = "socket2" version = "0.3.12" @@ -2141,11 +2224,13 @@ dependencies = [ "actix-rt", "actix-threadpool", "async-native-tls", + "async-rustls", "async-std", "native-tls", "once_cell", "tokio", "tokio-native-tls", + "tokio-rustls", ] [[package]] @@ -2511,6 +2596,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" +dependencies = [ + "futures-core", + "rustls", + "tokio", + "webpki", +] + [[package]] name = "toml" version = "0.5.6" @@ -2576,6 +2673,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.1.1" @@ -2599,6 +2702,12 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" +[[package]] +name = "vec-arena" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eafc1b9b2dfc6f5529177b62cf806484db55b32dc7c9658a118e11bbeb33061d" + [[package]] name = "vec_map" version = "0.8.2" @@ -2710,6 +2819,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "wepoll-sys-stjepang" version = "1.0.6" diff --git a/Cargo.toml b/Cargo.toml index 11729527ff..89801991d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ features = [ "all" ] rustdoc-args = ["--cfg", "docsrs"] [features] -default = [ "macros", "runtime-async-std", "migrate" ] +default = [ "macros", "runtime-async-std-native-tls", "migrate" ] macros = [ "sqlx-macros" ] migrate = [ "sqlx-macros/migrate", "sqlx-core/migrate" ] @@ -52,10 +52,25 @@ all = [ "tls", "all-databases", "all-types" ] all-databases = [ "mysql", "sqlite", "postgres", "mssql", "any" ] all-types = [ "bigdecimal", "decimal", "json", "time", "chrono", "ipnetwork", "uuid", "bit-vec" ] -# runtime -runtime-async-std = [ "sqlx-core/runtime-async-std", "sqlx-macros/runtime-async-std" ] -runtime-actix = [ "sqlx-core/runtime-actix", "sqlx-macros/runtime-actix" ] -runtime-tokio = [ "sqlx-core/runtime-tokio", "sqlx-macros/runtime-tokio" ] +# previous runtimes, available as features for error messages better than just +# "feature doesn't exist" +runtime-actix = [] +runtime-async-std = [] +runtime-tokio = [] + +# actual runtimes +runtime-actix-native-tls = [ "sqlx-core/runtime-actix-native-tls", "sqlx-macros/runtime-actix-native-tls", "_rt-actix" ] +runtime-async-std-native-tls = [ "sqlx-core/runtime-async-std-native-tls", "sqlx-macros/runtime-async-std-native-tls", "_rt-async-std" ] +runtime-tokio-native-tls = [ "sqlx-core/runtime-tokio-native-tls", "sqlx-macros/runtime-tokio-native-tls", "_rt-tokio" ] + +runtime-actix-rustls = [ "sqlx-core/runtime-actix-rustls", "sqlx-macros/runtime-actix-rustls", "_rt-actix" ] +runtime-async-std-rustls = [ "sqlx-core/runtime-async-std-rustls", "sqlx-macros/runtime-async-std-rustls", "_rt-async-std" ] +runtime-tokio-rustls = [ "sqlx-core/runtime-tokio-rustls", "sqlx-macros/runtime-tokio-rustls", "_rt-tokio" ] + +# for conditional compilation +_rt-actix = [] +_rt-async-std = [] +_rt-tokio = [] # database any = [ "sqlx-core/any" ] diff --git a/README.md b/README.md index 6d75852720..ee8f4daf00 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ SQLx is an async, pure Rust SQL crate featuring compile-time check * **Pure Rust**. The Postgres and MySQL/MariaDB drivers are written in pure Rust using **zero** unsafe†† code. - * **Runtime Agnostic**. Works on [async-std](https://crates.io/crates/async-std) or [tokio](https://crates.io/crates/tokio) with the `runtime-async-std` or `runtime-tokio` cargo feature flag. + * **Runtime Agnostic**. Works on different runtimes ([async-std](https://crates.io/crates/async-std) / [tokio](https://crates.io/crates/tokio) / [actix](https://crates.io/crates/actix-rt)) and TLS backends ([native-tls](https://crates.io/crates/native-tls), [rustls](https://crates.io/crates/rustls)). † The SQLite driver uses the libsqlite3 C library as SQLite is an embedded database (the only way we could be pure Rust for SQLite is by porting _all_ of SQLite to Rust). @@ -103,32 +103,37 @@ with C, those interactions are `unsafe`. ## Install -SQLx is compatible with the [`async-std`] and [`tokio`] runtimes. +SQLx is compatible with the [`async-std`], [`tokio`] and [`actix`] runtimes. [`async-std`]: https://github.com/async-rs/async-std [`tokio`]: https://github.com/tokio-rs/tokio +[`actix`]: https://github.com/actix/actix-net -**async-std** +You can also select between [`native-tls`] and [`rustls`] for the TLS backend. -```toml -# Cargo.toml -[dependencies] -sqlx = "0.4.0-beta.1" -``` - -**tokio** +By default, you get `async-std` + `native-tls`. If you want a different runtime or TLS backend, just disable the default features and activate the corresponding feature, for example for tokio + rustls: ```toml # Cargo.toml [dependencies] -sqlx = { version = "0.4.0-beta.1", default-features = false, features = [ "runtime-tokio", "macros" ] } +sqlx = { version = "0.4.0-beta.1", default-features = false, features = [ "runtime-tokio-rustls", "macros" ] } ``` +The runtime and TLS backend not being separate feature sets to select is a workaround for a [Cargo issue](https://github.com/rust-lang/cargo/issues/3494). + #### Cargo Feature Flags - * `runtime-async-std` (on by default): Use the `async-std` runtime. + * `runtime-async-std-native-tls` (on by default): Use the `async-std` runtime and `native-tls` TLS backend. + + * `runtime-async-std-rustls`: Use the `async-std` runtime and `rustls` TLS backend. + + * `runtime-tokio-native-tls`: Use the `tokio` runtime and `native-tls` TLS backend. + + * `runtime-tokio-rustls`: Use the `tokio` runtime and `rustls` TLS backend. + + * `runtime-actix-native-tls`: Use the `actix` runtime and `native-tls` TLS backend. - * `runtime-tokio`: Use the `tokio` runtime. Mutually exclusive with the `runtime-async-std` feature. + * `runtime-actix-rustls`: Use the `actix` runtime and `rustls` TLS backend. * `postgres`: Add support for the Postgres database server. diff --git a/sqlx-bench/Cargo.toml b/sqlx-bench/Cargo.toml index 5498499559..9e3f123327 100644 --- a/sqlx-bench/Cargo.toml +++ b/sqlx-bench/Cargo.toml @@ -6,9 +6,13 @@ edition = "2018" publish = false [features] -runtime-actix = ["sqlx/runtime-actix", "sqlx-rt/runtime-actix"] -runtime-async-std = ["sqlx/runtime-async-std", "sqlx-rt/runtime-async-std"] -runtime-tokio = ["sqlx/runtime-tokio", "sqlx-rt/runtime-tokio"] +runtime-actix-native-tls = [ "sqlx/runtime-actix-native-tls", "sqlx-rt/runtime-actix-native-tls" ] +runtime-async-std-native-tls = [ "sqlx/runtime-async-std-native-tls", "sqlx-rt/runtime-async-std-native-tls" ] +runtime-tokio-native-tls = [ "sqlx/runtime-tokio-native-tls", "sqlx-rt/runtime-tokio-native-tls" ] + +runtime-actix-rustls = [ "sqlx/runtime-actix-rustls", "sqlx-rt/runtime-actix-rustls" ] +runtime-async-std-rustls = [ "sqlx/runtime-async-std-rustls", "sqlx-rt/runtime-async-std-rustls" ] +runtime-tokio-rustls = [ "sqlx/runtime-tokio-rustls", "sqlx-rt/runtime-tokio-rustls" ] postgres = ["sqlx/postgres"] diff --git a/sqlx-bench/README.md b/sqlx-bench/README.md index 9fa8b60790..ca21933631 100644 --- a/sqlx-bench/README.md +++ b/sqlx-bench/README.md @@ -23,8 +23,8 @@ This Cargo project implements various benchmarks for SQLx using You must choose a runtime to execute the benchmarks on; the feature flags are the same as the `sqlx` crate: ```bash -cargo bench --features runtime-tokio -cargo bench --features runtime-async-std +cargo bench --features runtime-tokio-native-tls +cargo bench --features runtime-async-std-rustls ``` When complete, the benchmark results will be in `target/criterion/`. diff --git a/sqlx-cli/Cargo.toml b/sqlx-cli/Cargo.toml index 8ffe1a1764..e779e4658d 100644 --- a/sqlx-cli/Cargo.toml +++ b/sqlx-cli/Cargo.toml @@ -27,7 +27,7 @@ path = "src/bin/cargo-sqlx.rs" [dependencies] dotenv = "0.15" tokio = { version = "0.2", features = ["macros"] } -sqlx = { version = "0.4.0-beta.1", path = "..", default-features = false, features = [ "runtime-async-std", "migrate", "any", "offline" ] } +sqlx = { version = "0.4.0-beta.1", path = "..", default-features = false, features = [ "runtime-async-std-native-tls", "migrate", "any", "offline" ] } futures = "0.3" clap = "=3.0.0-beta.2" chrono = "0.4" diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index 7b91ba68b2..03e4d64818 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -13,7 +13,7 @@ authors = [ ] [features] -default = [ "runtime-async-std", "migrate" ] +default = [ "runtime-async-std-native-tls", "migrate" ] migrate = [ "sha2", "crc" ] # databases @@ -31,9 +31,18 @@ decimal = [ "rust_decimal", "num-bigint" ] json = [ "serde", "serde_json" ] # runtimes -runtime-async-std = [ "sqlx-rt/runtime-async-std" ] -runtime-tokio = [ "sqlx-rt/runtime-tokio" ] -runtime-actix = [ "sqlx-rt/runtime-actix" ] +runtime-actix-native-tls = [ "sqlx-rt/runtime-actix-native-tls", "_rt-actix" ] +runtime-async-std-native-tls = [ "sqlx-rt/runtime-async-std-native-tls", "_rt-async-std" ] +runtime-tokio-native-tls = [ "sqlx-rt/runtime-tokio-native-tls", "_rt-tokio" ] + +runtime-actix-rustls = [ "sqlx-rt/runtime-actix-rustls", "_rt-actix" ] +runtime-async-std-rustls = [ "sqlx-rt/runtime-async-std-rustls", "_rt-async-std" ] +runtime-tokio-rustls = [ "sqlx-rt/runtime-tokio-rustls", "_rt-tokio" ] + +# for conditional compilation +_rt-actix = [] +_rt-async-std = [] +_rt-tokio = [] # support offline/decoupled building (enables serialization of `Describe`) offline = [ "serde", "either/serde" ] diff --git a/sqlx-core/src/mysql/connection/tls.rs b/sqlx-core/src/mysql/connection/tls.rs index 4627779a46..2ed47a6e35 100644 --- a/sqlx-core/src/mysql/connection/tls.rs +++ b/sqlx-core/src/mysql/connection/tls.rs @@ -67,10 +67,10 @@ async fn upgrade(stream: &mut MySqlStream, options: &MySqlConnectOptions) -> Res } } - #[cfg(not(feature = "runtime-async-std"))] + #[cfg(not(feature = "_rt-async-std"))] let connector = builder.build().map_err(Error::tls)?; - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] let connector = builder; stream.upgrade(&options.host, connector.into()).await?; diff --git a/sqlx-core/src/mysql/options/mod.rs b/sqlx-core/src/mysql/options/mod.rs index ea7862fd22..08f417029a 100644 --- a/sqlx-core/src/mysql/options/mod.rs +++ b/sqlx-core/src/mysql/options/mod.rs @@ -34,7 +34,7 @@ pub use ssl_mode::MySqlSslMode; /// # use sqlx_core::mysql::{MySqlConnectOptions, MySqlConnection, MySqlSslMode}; /// # /// # fn main() { -/// # #[cfg(feature = "runtime-async-std")] +/// # #[cfg(feature = "_rt-async-std")] /// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move { /// // URI connection string /// let conn = MySqlConnection::connect("mysql://root:password@localhost/db").await?; diff --git a/sqlx-core/src/net/socket.rs b/sqlx-core/src/net/socket.rs index 29a17a7494..929335b388 100644 --- a/sqlx-core/src/net/socket.rs +++ b/sqlx-core/src/net/socket.rs @@ -60,7 +60,7 @@ impl AsyncRead for Socket { } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_read_buf( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -102,7 +102,7 @@ impl AsyncWrite for Socket { } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut *self { Socket::Tcp(s) => Pin::new(s).poll_shutdown(cx), @@ -112,7 +112,7 @@ impl AsyncWrite for Socket { } } - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut *self { Socket::Tcp(s) => Pin::new(s).poll_close(cx), @@ -122,7 +122,7 @@ impl AsyncWrite for Socket { } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_write_buf( mut self: Pin<&mut Self>, cx: &mut Context<'_>, diff --git a/sqlx-core/src/net/tls.rs b/sqlx-core/src/net/tls.rs index 9e0463af5a..89c1b91d31 100644 --- a/sqlx-core/src/net/tls.rs +++ b/sqlx-core/src/net/tls.rs @@ -72,7 +72,7 @@ where } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_read_buf( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -117,7 +117,7 @@ where } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut *self { MaybeTlsStream::Raw(s) => Pin::new(s).poll_shutdown(cx), @@ -127,7 +127,7 @@ where } } - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match &mut *self { MaybeTlsStream::Raw(s) => Pin::new(s).poll_close(cx), @@ -137,7 +137,7 @@ where } } - #[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))] + #[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))] fn poll_write_buf( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -166,10 +166,10 @@ where match self { MaybeTlsStream::Raw(s) => s, - #[cfg(not(feature = "runtime-async-std"))] + #[cfg(not(feature = "_rt-async-std"))] MaybeTlsStream::Tls(s) => s.get_ref().get_ref().get_ref(), - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] MaybeTlsStream::Tls(s) => s.get_ref(), MaybeTlsStream::Upgrading => panic!(io::Error::from(io::ErrorKind::ConnectionAborted)), @@ -185,10 +185,10 @@ where match self { MaybeTlsStream::Raw(s) => s, - #[cfg(not(feature = "runtime-async-std"))] + #[cfg(not(feature = "_rt-async-std"))] MaybeTlsStream::Tls(s) => s.get_mut().get_mut().get_mut(), - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] MaybeTlsStream::Tls(s) => s.get_mut(), MaybeTlsStream::Upgrading => panic!(io::Error::from(io::ErrorKind::ConnectionAborted)), diff --git a/sqlx-core/src/postgres/connection/tls.rs b/sqlx-core/src/postgres/connection/tls.rs index 80fadc5b6b..03cbd6ae67 100644 --- a/sqlx-core/src/postgres/connection/tls.rs +++ b/sqlx-core/src/postgres/connection/tls.rs @@ -84,10 +84,10 @@ async fn upgrade(stream: &mut PgStream, options: &PgConnectOptions) -> Result>(async move { /// # let mut listener = PgListener::connect("postgres:// ...").await?; /// loop { @@ -183,7 +183,7 @@ impl PgListener { /// # use sqlx_core::postgres::PgListener; /// # use sqlx_core::error::Error; /// # - /// # #[cfg(feature = "runtime-async-std")] + /// # #[cfg(feature = "_rt-async-std")] /// # sqlx_rt::block_on::<_, Result<(), Error>>(async move { /// # let mut listener = PgListener::connect("postgres:// ...").await?; /// loop { diff --git a/sqlx-core/src/postgres/options/mod.rs b/sqlx-core/src/postgres/options/mod.rs index 6d6a74a7f9..684c5e6f4a 100644 --- a/sqlx-core/src/postgres/options/mod.rs +++ b/sqlx-core/src/postgres/options/mod.rs @@ -53,7 +53,7 @@ pub use ssl_mode::PgSslMode; /// # use sqlx_core::postgres::{PgConnectOptions, PgConnection, PgSslMode}; /// # /// # fn main() { -/// # #[cfg(feature = "runtime-async-std")] +/// # #[cfg(feature = "_rt-async-std")] /// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move { /// // URI connection string /// let conn = PgConnection::connect("postgres://localhost/mydb").await?; diff --git a/sqlx-core/src/sqlite/options/mod.rs b/sqlx-core/src/sqlite/options/mod.rs index 824e0bcb3a..518e682cd6 100644 --- a/sqlx-core/src/sqlite/options/mod.rs +++ b/sqlx-core/src/sqlite/options/mod.rs @@ -30,7 +30,7 @@ use std::{borrow::Cow, time::Duration}; /// use std::str::FromStr; /// /// # fn main() { -/// # #[cfg(feature = "runtime-async-std")] +/// # #[cfg(feature = "_rt-async-std")] /// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move { /// let conn = SqliteConnectOptions::from_str("sqlite://data.db")? /// .journal_mode(SqliteJournalMode::Wal) diff --git a/sqlx-macros/Cargo.toml b/sqlx-macros/Cargo.toml index 1285d4ceb8..e713eac1da 100644 --- a/sqlx-macros/Cargo.toml +++ b/sqlx-macros/Cargo.toml @@ -16,13 +16,22 @@ authors = [ proc-macro = true [features] -default = [ "runtime-async-std", "migrate" ] +default = [ "runtime-async-std-native-tls", "migrate" ] migrate = [ "sha2" ] # runtimes -runtime-async-std = [ "sqlx-core/runtime-async-std", "sqlx-rt/runtime-async-std" ] -runtime-tokio = [ "sqlx-core/runtime-tokio", "sqlx-rt/runtime-tokio" ] -runtime-actix = [ "sqlx-core/runtime-actix", "sqlx-rt/runtime-actix" ] +runtime-actix-native-tls = [ "sqlx-core/runtime-actix-native-tls", "sqlx-rt/runtime-actix-native-tls", "_rt-actix" ] +runtime-async-std-native-tls = [ "sqlx-core/runtime-async-std-native-tls", "sqlx-rt/runtime-async-std-native-tls", "_rt-async-std" ] +runtime-tokio-native-tls = [ "sqlx-core/runtime-tokio-native-tls", "sqlx-rt/runtime-tokio-native-tls", "_rt-tokio" ] + +runtime-actix-rustls = [ "sqlx-core/runtime-actix-rustls", "sqlx-rt/runtime-actix-rustls", "_rt-actix" ] +runtime-async-std-rustls = [ "sqlx-core/runtime-async-std-rustls", "sqlx-rt/runtime-async-std-rustls", "_rt-async-std" ] +runtime-tokio-rustls = [ "sqlx-core/runtime-tokio-rustls", "sqlx-rt/runtime-tokio-rustls", "_rt-tokio" ] + +# for conditional compilation +_rt-actix = [] +_rt-async-std = [] +_rt-tokio = [] # offline building support offline = ["sqlx-core/offline", "serde", "serde_json", "hex", "sha2"] diff --git a/sqlx-macros/src/lib.rs b/sqlx-macros/src/lib.rs index 31fdead14d..b42f202787 100644 --- a/sqlx-macros/src/lib.rs +++ b/sqlx-macros/src/lib.rs @@ -103,7 +103,7 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream { let body = &input.block; let attrs = &input.attrs; - let result = if cfg!(feature = "runtime-tokio") { + let result = if cfg!(feature = "_rt-tokio") { quote! { #[test] #(#attrs)* @@ -117,7 +117,7 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream { .block_on(async { #body }) } } - } else if cfg!(feature = "runtime-async-std") { + } else if cfg!(feature = "_rt-async-std") { quote! { #[test] #(#attrs)* @@ -125,7 +125,7 @@ pub fn test(_attr: TokenStream, input: TokenStream) -> TokenStream { sqlx_rt::async_std::task::block_on(async { #body }) } } - } else if cfg!(feature = "runtime-actix") { + } else if cfg!(feature = "_rt-actix") { quote! { #[test] #(#attrs)* diff --git a/sqlx-rt/Cargo.toml b/sqlx-rt/Cargo.toml index 92192df7e1..d55adb8c30 100644 --- a/sqlx-rt/Cargo.toml +++ b/sqlx-rt/Cargo.toml @@ -11,16 +11,29 @@ authors = [ ] [features] -runtime-actix = [ "actix-rt", "actix-threadpool", "tokio", "tokio-native-tls", "once_cell" ] -runtime-async-std = [ "async-std", "async-native-tls" ] -runtime-tokio = [ "tokio", "tokio-native-tls", "once_cell" ] +runtime-actix-native-tls = [ "_rt-actix", "_tls-native-tls", "tokio-native-tls" ] +runtime-async-std-native-tls = [ "_rt-async-std", "_tls-native-tls", "async-native-tls" ] +runtime-tokio-native-tls = [ "_rt-tokio", "_tls-native-tls", "tokio-native-tls" ] + +runtime-actix-rustls = [ "_rt-actix", "_tls-rustls", "tokio-rustls" ] +runtime-async-std-rustls = [ "_rt-async-std", "_tls-rustls", "async-rustls" ] +runtime-tokio-rustls = [ "_rt-tokio", "_tls-rustls", "tokio-rustls" ] + +# Not used directly and not re-exported from sqlx +_rt-actix = [ "actix-rt", "actix-threadpool", "tokio", "once_cell" ] +_rt-async-std = [ "async-std" ] +_rt-tokio = [ "tokio", "once_cell" ] +_tls-native-tls = [ "native-tls" ] +_tls-rustls = [ ] [dependencies] -async-native-tls = { version = "0.3.3", optional = true } actix-rt = { version = "1.1.1", optional = true } -actix-threadpool = { version = "0.3.2", optional = true } -async-std = { version = "1.6.0", features = [ "unstable" ], optional = true } -tokio = { version = "0.2.21", optional = true, features = [ "blocking", "stream", "fs", "tcp", "uds", "macros", "rt-core", "rt-threaded", "time", "dns", "io-util" ] } -tokio-native-tls = { version = "0.1.0", optional = true } -native-tls = "0.2.4" +actix-threadpool = { version = "0.3.3", optional = true } +async-native-tls = { version = "0.3.3", optional = true } +async-rustls = { version = "0.1.1", optional = true } +async-std = { version = "1.6.5", features = [ "unstable" ], optional = true } +native-tls = { version = "0.2.4", optional = true } once_cell = { version = "1.4", features = ["std"], optional = true } +tokio = { version = "0.2.22", optional = true, features = [ "blocking", "stream", "fs", "tcp", "uds", "macros", "rt-core", "rt-threaded", "time", "dns", "io-util" ] } +tokio-native-tls = { version = "0.1.0", optional = true } +tokio-rustls = { version = "0.14.1", optional = true } diff --git a/sqlx-rt/src/lib.rs b/sqlx-rt/src/lib.rs index e562374e36..cbe2a4f817 100644 --- a/sqlx-rt/src/lib.rs +++ b/sqlx-rt/src/lib.rs @@ -1,21 +1,30 @@ #[cfg(not(any( - feature = "runtime-actix", - feature = "runtime-async-std", - feature = "runtime-tokio", + feature = "runtime-actix-native-tls", + feature = "runtime-async-std-native-tls", + feature = "runtime-tokio-native-tls", + feature = "runtime-actix-rustls", + feature = "runtime-async-std-rustls", + feature = "runtime-tokio-rustls", )))] compile_error!( - "one of 'runtime-actix', 'runtime-async-std' or 'runtime-tokio' features must be enabled" + "one of the features ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \ + 'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \ + 'runtime-tokio-rustls'] 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"), + all(feature = "_rt-actix", feature = "_rt-async-std"), + all(feature = "_rt-actix", feature = "_rt-tokio"), + all(feature = "_rt-async-std", feature = "_rt-tokio"), + all(feature = "_tls-native-tls", feature = "_tls-rustls"), ))] compile_error!( - "only one of 'runtime-actix', 'runtime-async-std' or 'runtime-tokio' features can be enabled" + "only one of ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \ + 'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \ + 'runtime-tokio-rustls'] can be enabled" ); +#[cfg(all(feature = "_tls-native-tls", not(feature = "_tls-rustls")))] pub use native_tls::{self, Error as TlsError}; // @@ -23,8 +32,8 @@ pub use native_tls::{self, Error as TlsError}; // #[cfg(all( - not(feature = "runtime-async-std"), - any(feature = "runtime-tokio", feature = "runtime-actix"), + any(feature = "_rt-tokio", feature = "_rt-actix"), + not(feature = "_rt-async-std"), ))] pub use tokio::{ self, fs, io::AsyncRead, io::AsyncReadExt, io::AsyncWrite, io::AsyncWriteExt, net::TcpStream, @@ -33,12 +42,16 @@ pub use tokio::{ #[cfg(all( unix, - not(feature = "runtime-async-std"), - any(feature = "runtime-tokio", feature = "runtime-actix"), + any(feature = "_rt-tokio", feature = "_rt-actix"), + not(feature = "_rt-async-std"), ))] pub use tokio::net::UnixStream; -#[cfg(all(feature = "tokio-native-tls", not(feature = "async-native-tls")))] +#[cfg(all( + feature = "_tls-native-tls", + any(feature = "_rt-tokio", feature = "_rt-actix"), + not(feature = "_rt-async-std"), +))] pub use tokio_native_tls::{TlsConnector, TlsStream}; // @@ -46,8 +59,8 @@ pub use tokio_native_tls::{TlsConnector, TlsStream}; // #[cfg(all( - feature = "runtime-tokio", - not(any(feature = "runtime-actix", feature = "runtime-async-std",)) + feature = "_rt-tokio", + not(any(feature = "_rt-actix", feature = "_rt-async-std")), ))] #[macro_export] macro_rules! blocking { @@ -60,12 +73,12 @@ macro_rules! blocking { // actix // -#[cfg(feature = "runtime-actix")] +#[cfg(feature = "_rt-actix")] pub use {actix_rt, actix_threadpool}; #[cfg(all( - feature = "runtime-actix", - not(any(feature = "runtime-tokio", feature = "runtime-async-std",)) + feature = "_rt-actix", + not(any(feature = "_rt-tokio", feature = "_rt-async-std")), ))] #[macro_export] macro_rules! blocking { @@ -82,8 +95,8 @@ macro_rules! blocking { // #[cfg(all( - feature = "runtime-async-std", - not(any(feature = "runtime-actix", feature = "runtime-tokio",)) + feature = "_rt-async-std", + not(any(feature = "_rt-actix", feature = "_rt-tokio")), ))] pub use async_std::{ self, fs, future::timeout, io::prelude::ReadExt as AsyncReadExt, @@ -92,8 +105,8 @@ pub use async_std::{ }; #[cfg(all( - feature = "runtime-async-std", - not(any(feature = "runtime-actix", feature = "runtime-tokio",)) + feature = "_rt-async-std", + not(any(feature = "_rt-actix", feature = "_rt-tokio")), ))] #[macro_export] macro_rules! blocking { @@ -104,8 +117,8 @@ macro_rules! blocking { #[cfg(all( unix, - feature = "runtime-async-std", - not(any(feature = "runtime-actix", feature = "runtime-tokio",)) + feature = "_rt-async-std", + not(any(feature = "_rt-actix", feature = "_rt-tokio")), ))] pub use async_std::os::unix::net::UnixStream; @@ -113,14 +126,14 @@ pub use async_std::os::unix::net::UnixStream; pub use async_native_tls::{TlsConnector, TlsStream}; #[cfg(all( - feature = "runtime-async-std", - not(any(feature = "runtime-actix", feature = "runtime-tokio")) + feature = "_rt-async-std", + not(any(feature = "_rt-actix", feature = "_rt-tokio")), ))] pub use async_std::task::block_on; #[cfg(all( - feature = "runtime-async-std", - not(any(feature = "runtime-actix", feature = "runtime-tokio")) + feature = "_rt-async-std", + not(any(feature = "_rt-actix", feature = "_rt-tokio")), ))] pub fn enter_runtime(f: F) -> R where @@ -131,12 +144,12 @@ where } #[cfg(all( - any(feature = "runtime-tokio", feature = "runtime-actix"), - not(feature = "runtime-async-std") + any(feature = "_rt-tokio", feature = "_rt-actix"), + not(feature = "_rt-async-std"), ))] pub use tokio_runtime::{block_on, enter_runtime}; -#[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))] +#[cfg(any(feature = "_rt-tokio", feature = "_rt-actix"))] mod tokio_runtime { use once_cell::sync::Lazy; use tokio::runtime::{self, Runtime}; @@ -152,7 +165,7 @@ mod tokio_runtime { .expect("failed to initialize Tokio runtime") }); - #[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))] + #[cfg(any(feature = "_rt-tokio", feature = "_rt-actix"))] pub fn block_on(future: F) -> F::Output { RUNTIME.enter(|| RUNTIME.handle().block_on(future)) } diff --git a/src/lib.rs b/src/lib.rs index 218dc60b1b..e2a404b074 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,16 @@ #![cfg_attr(docsrs, feature(doc_cfg))] +#[cfg(any( + feature = "runtime-actix", + feature = "runtime-async-std", + feature = "runtime-tokio" +))] +compile_error!( + "the features 'runtime-actix', 'runtime-async-std' and 'runtime-tokio' have been removed in + favor of new features 'runtime-{rt}-{tls}' where rt is one of 'actix', 'async-std' and 'tokio' + and 'tls' is one of 'native-tls' and 'rustls'." +); + pub use sqlx_core::acquire::Acquire; pub use sqlx_core::arguments::{Arguments, IntoArguments}; pub use sqlx_core::column::Column; diff --git a/src/macros.rs b/src/macros.rs index c165a9525e..76abea48e2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -5,7 +5,7 @@ /// /// ```rust,ignore /// # use sqlx::Connect; -/// # #[cfg(all(feature = "mysql", feature = "runtime-async-std"))] +/// # #[cfg(all(feature = "mysql", feature = "_rt-async-std"))] /// # #[async_std::main] /// # async fn main() -> sqlx::Result<()>{ /// # let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -24,7 +24,7 @@ /// # Ok(()) /// # } /// # -/// # #[cfg(any(not(feature = "mysql"), not(feature = "runtime-async-std")))] +/// # #[cfg(any(not(feature = "mysql"), not(feature = "_rt-async-std")))] /// # fn main() {} /// ``` /// @@ -54,7 +54,7 @@ /// /// ```rust,ignore /// # use sqlx::Connect; -/// # #[cfg(all(feature = "mysql", feature = "runtime-async-std"))] +/// # #[cfg(all(feature = "mysql", feature = "_rt-async-std"))] /// # #[async_std::main] /// # async fn main() -> sqlx::Result<()>{ /// # let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -75,7 +75,7 @@ /// # Ok(()) /// # } /// # -/// # #[cfg(any(not(feature = "mysql"), not(feature = "runtime-async-std")))] +/// # #[cfg(any(not(feature = "mysql"), not(feature = "_rt-async-std")))] /// # fn main() {} /// ``` /// @@ -328,7 +328,7 @@ macro_rules! query_unchecked ( /// `src/my_query.rs`: /// ```rust,ignore /// # use sqlx::Connect; -/// # #[cfg(all(feature = "mysql", feature = "runtime-async-std"))] +/// # #[cfg(all(feature = "mysql", feature = "_rt-async-std"))] /// # #[async_std::main] /// # async fn main() -> sqlx::Result<()>{ /// # let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -345,7 +345,7 @@ macro_rules! query_unchecked ( /// # Ok(()) /// # } /// # -/// # #[cfg(any(not(feature = "mysql"), not(feature = "runtime-async-std")))] +/// # #[cfg(any(not(feature = "mysql"), not(feature = "_rt-async-std")))] /// # fn main() {} /// ``` #[macro_export] @@ -397,7 +397,7 @@ macro_rules! query_file_unchecked ( /// string: /// ```rust,ignore /// # use sqlx::Connect; -/// # #[cfg(all(feature = "mysql", feature = "runtime-async-std"))] +/// # #[cfg(all(feature = "mysql", feature = "_rt-async-std"))] /// # #[async_std::main] /// # async fn main() -> sqlx::Result<()>{ /// # let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -425,7 +425,7 @@ macro_rules! query_file_unchecked ( /// # Ok(()) /// # } /// # -/// # #[cfg(any(not(feature = "mysql"), not(feature = "runtime-async-std")))] +/// # #[cfg(any(not(feature = "mysql"), not(feature = "_rt-async-std")))] /// # fn main() {} /// ``` /// @@ -526,7 +526,7 @@ macro_rules! query_as ( /// /// ```rust,ignore /// # use sqlx::Connect; -/// # #[cfg(all(feature = "mysql", feature = "runtime-async-std"))] +/// # #[cfg(all(feature = "mysql", feature = "_rt-async-std"))] /// # #[async_std::main] /// # async fn main() -> sqlx::Result<()>{ /// # let db_url = dotenv::var("DATABASE_URL").expect("DATABASE_URL must be set"); @@ -550,7 +550,7 @@ macro_rules! query_as ( /// # Ok(()) /// # } /// # -/// # #[cfg(any(not(feature = "mysql"), not(feature = "runtime-async-std")))] +/// # #[cfg(any(not(feature = "mysql"), not(feature = "_rt-async-std")))] /// # fn main() {} /// ``` #[macro_export] diff --git a/tests/mysql/mysql.rs b/tests/mysql/mysql.rs index fa69ee3914..52d1f94361 100644 --- a/tests/mysql/mysql.rs +++ b/tests/mysql/mysql.rs @@ -335,7 +335,7 @@ async fn it_can_prepare_then_execute() -> anyhow::Result<()> { } // repro is more reliable with the basic scheduler used by `#[tokio::test]` -#[cfg(feature = "runtime-tokio")] +#[cfg(feature = "_rt-tokio")] #[tokio::test] async fn test_issue_622() -> anyhow::Result<()> { use std::time::Instant; diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index f64a6b0a5a..1cbf9e6c91 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -454,10 +454,10 @@ async fn it_can_drop_multiple_transactions() -> anyhow::Result<()> { #[ignore] #[sqlx_macros::test] async fn pool_smoke_test() -> anyhow::Result<()> { - #[cfg(any(feature = "runtime-tokio", feature = "runtime-actix"))] + #[cfg(any(feature = "_rt-tokio", feature = "_rt-actix"))] use tokio::{task::spawn, time::delay_for as sleep, time::timeout}; - #[cfg(feature = "runtime-async-std")] + #[cfg(feature = "_rt-async-std")] use async_std::{future::timeout, task::sleep, task::spawn}; eprintln!("starting pool"); @@ -711,7 +711,7 @@ async fn it_can_prepare_then_execute() -> anyhow::Result<()> { } // repro is more reliable with the basic scheduler used by `#[tokio::test]` -#[cfg(feature = "runtime-tokio")] +#[cfg(feature = "_rt-tokio")] #[tokio::test] async fn test_issue_622() -> anyhow::Result<()> { use std::time::Instant;