Skip to content

Commit e944b0a

Browse files
committed
Use TLS backend feature names
1 parent 6c0cd17 commit e944b0a

35 files changed

Lines changed: 162 additions & 193 deletions

File tree

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
--workspace \
3030
--token ${{ secrets.CRATES_TOKEN }} \
3131
--no-default-features \
32-
--features runtime-actix-rustls
32+
--features rustls

.github/workflows/sqlx.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ jobs:
3030
run: |
3131
cargo clippy --manifest-path sqlx-core/Cargo.toml \
3232
--no-default-features \
33-
--features offline,all-databases,all-types,migrate,runtime-tokio-${{ matrix.tls }} \
33+
--features offline,all-databases,all-types,migrate,${{ matrix.tls }} \
3434
-- -D warnings
3535
- name: Run clippy for root with all features
3636
run: |
3737
cargo clippy \
3838
--no-default-features \
39-
--features offline,all-databases,all-types,migrate,runtime-tokio-${{ matrix.tls }},macros \
39+
--features offline,all-databases,all-types,migrate,${{ matrix.tls }},macros \
4040
-- -D warnings
4141
- name: Run clippy for all targets
4242
run: |
4343
cargo clippy \
4444
--no-default-features \
4545
--all-targets \
46-
--features offline,all-databases,all-types,migrate,runtime-tokio-${{ matrix.tls }} \
46+
--features offline,all-databases,all-types,migrate,${{ matrix.tls }} \
4747
-- -D warnings
4848
4949
test:
@@ -62,7 +62,7 @@ jobs:
6262
if: ${{ matrix.os == 'ubuntu-latest' }}
6363
- run: cargo test
6464
--manifest-path sqlx-core/Cargo.toml
65-
--features offline,all-databases,all-types,runtime-tokio-rustls
65+
--features offline,all-databases,all-types,rustls
6666

6767
cli:
6868
name: CLI Binaries
@@ -119,11 +119,11 @@ jobs:
119119
run: |
120120
cargo clippy \
121121
--no-default-features \
122-
--features sqlite,all-types,runtime-tokio-${{ matrix.tls }},macros,migrate \
122+
--features sqlite,all-types,${{ matrix.tls }},macros,migrate \
123123
-- -D warnings
124124
- run: cargo test
125125
--no-default-features
126-
--features any,macros,migrate,sqlite,all-types,runtime-tokio-${{ matrix.tls }}
126+
--features any,macros,migrate,sqlite,all-types,${{ matrix.tls }}
127127
env:
128128
DATABASE_URL: sqlite://tests/sqlite/sqlite.db
129129
RUSTFLAGS: --cfg sqlite_ipaddr
@@ -147,7 +147,7 @@ jobs:
147147
save-if: ${{ github.ref == 'refs/heads/main' && matrix.postgres == '14' }}
148148

149149
- run: |
150-
cargo build --features postgres,all-types,runtime-tokio-${{ matrix.tls }}
150+
cargo build --features postgres,all-types,${{ matrix.tls }}
151151
env:
152152
# FIXME: needed to disable `ltree` tests in Postgres 9.6
153153
# but `PgLTree` should just fall back to text format
@@ -157,7 +157,7 @@ jobs:
157157
run: |
158158
cargo clippy \
159159
--no-default-features \
160-
--features postgres,all-types,runtime-tokio-${{ matrix.tls }},macros,migrate \
160+
--features postgres,all-types,${{ matrix.tls }},macros,migrate \
161161
-- -D warnings
162162
env:
163163
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
@@ -167,15 +167,15 @@ jobs:
167167
docker exec postgres_${{ matrix.postgres }} bash -c "until pg_isready; do sleep 1; done"
168168
169169
- run: |
170-
cargo test --no-default-features --features any,postgres,macros,all-types,runtime-tokio-${{ matrix.tls }}
170+
cargo test --no-default-features --features any,postgres,macros,all-types,${{ matrix.tls }}
171171
env:
172172
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx
173173
# FIXME: needed to disable `ltree` tests in Postgres 9.6
174174
# but `PgLTree` should just fall back to text format
175175
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}
176176
177177
- run: |
178-
cargo test --no-default-features --features any,postgres,macros,migrate,all-types,runtime-tokio-${{ matrix.tls }}
178+
cargo test --no-default-features --features any,postgres,macros,migrate,all-types,${{ matrix.tls }}
179179
env:
180180
DATABASE_URL: postgres://postgres:password@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=./tests/certs/ca.crt
181181
# FIXME: needed to disable `ltree` tests in Postgres 9.6
@@ -191,11 +191,11 @@ jobs:
191191
- uses: Swatinem/rust-cache@65012b490220f477f20ab979e35ae732e6de4e68
192192
with:
193193
prefix-key: v1-sqlx
194-
shared-key: postgres-tokio-rustls
194+
shared-key: postgres-rustls
195195
save-if: ${{ false }}
196196
- run: docker compose up --wait postgres_16
197197
working-directory: tests
198-
- run: cargo test --no-default-features --features any,postgres,macros,all-types,runtime-tokio-rustls
198+
- run: cargo test --no-default-features --features any,postgres,macros,all-types,rustls
199199
env:
200200
DATABASE_URL: postgres://postgres@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=./tests/certs/ca.crt&sslcert=./tests/certs/client.crt&sslkey=./tests/keys/client.key
201201

@@ -217,26 +217,26 @@ jobs:
217217
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mysql == '8' }}
218218

219219
- run: |
220-
cargo build --features mysql,all-types,runtime-tokio-${{ matrix.tls }}
220+
cargo build --features mysql,all-types,${{ matrix.tls }}
221221
222222
- name: Run clippy for mysql
223223
run: |
224224
cargo clippy \
225225
--no-default-features \
226-
--features mysql,all-types,runtime-tokio-${{ matrix.tls }},macros,migrate \
226+
--features mysql,all-types,${{ matrix.tls }},macros,migrate \
227227
-- -D warnings
228228
229229
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mysql_${{ matrix.mysql }}
230230
- run: sleep 60
231231

232232
- run: |
233-
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,runtime-tokio-${{ matrix.tls }}
233+
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,${{ matrix.tls }}
234234
env:
235235
DATABASE_URL: mysql://root:password@localhost:3306/sqlx?ssl-mode=disabled
236236
237237
# MySQL 5.7 supports TLS but not TLSv1.3 as required by RusTLS.
238238
- run: |
239-
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,runtime-tokio-${{ matrix.tls }}
239+
cargo test --no-default-features --features any,mysql,macros,migrate,all-types,${{ matrix.tls }}
240240
if: ${{ !(matrix.mysql == '5_7' && matrix.tls == 'rustls') }}
241241
env:
242242
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
@@ -259,20 +259,20 @@ jobs:
259259
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mariadb == '10_6' }}
260260

261261
- run: |
262-
cargo build --features mysql,runtime-tokio-${{ matrix.tls }}
262+
cargo build --features mysql,${{ matrix.tls }}
263263
264264
- name: Run clippy for mariadb
265265
run: |
266266
cargo clippy \
267267
--no-default-features \
268-
--features mysql,runtime-tokio-${{ matrix.tls }},macros,migrate \
268+
--features mysql,${{ matrix.tls }},macros,migrate \
269269
-- -D warnings
270270
271271
- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mariadb_${{ matrix.mariadb }}
272272
- run: sleep 30
273273

274274
- run: |
275-
cargo test --no-default-features --features any,mysql,macros,migrate,runtime-tokio-${{ matrix.tls }}
275+
cargo test --no-default-features --features any,mysql,macros,migrate,${{ matrix.tls }}
276276
env:
277277
DATABASE_URL: mysql://root:password@localhost:3306/sqlx
278278
@@ -294,20 +294,20 @@ jobs:
294294
save-if: ${{ github.ref == 'refs/heads/main' && matrix.mssql == '2022' }}
295295

296296
- run: |
297-
cargo build --features mssql,all-types,runtime-tokio-${{ matrix.tls }}
297+
cargo build --features mssql,all-types,${{ matrix.tls }}
298298
299299
- name: Run clippy for mssql
300300
run: |
301301
cargo clippy \
302302
--no-default-features \
303-
--features mssql,all-types,runtime-tokio-${{ matrix.tls }},macros,migrate \
303+
--features mssql,all-types,${{ matrix.tls }},macros,migrate \
304304
-- -D warnings
305305
306306
- run: docker compose -f tests/docker-compose.yml run -d -p 1433:1433 mssql_${{ matrix.mssql }}
307307
- run: sleep 80 # MSSQL takes a "bit" to startup
308308

309309
- run: |
310-
cargo test --no-default-features --features any,mssql,macros,migrate,all-types,runtime-tokio-${{ matrix.tls }}
310+
cargo test --no-default-features --features any,mssql,macros,migrate,all-types,${{ matrix.tls }}
311311
env:
312312
DATABASE_URL: mssql://sa:Password123!@localhost/sqlx
313313
@@ -338,10 +338,10 @@ jobs:
338338
odbcinst -q -s || true
339339
echo "select 1;" | isql -v SQLX_PG_5432 || true
340340
- name: Run ODBC tests (PostgreSQL DSN)
341-
run: cargo test --no-default-features --features any,odbc,macros,all-types,runtime-tokio-rustls
341+
run: cargo test --no-default-features --features any,odbc,macros,all-types,rustls
342342
env:
343343
DATABASE_URL: DSN=SQLX_PG_5432;UID=postgres;PWD=password
344344
- name: Run ODBC tests (SQLite driver)
345-
run: cargo test --no-default-features --features any,odbc,macros,all-types,runtime-tokio-rustls
345+
run: cargo test --no-default-features --features any,odbc,macros,all-types,rustls
346346
env:
347347
DATABASE_URL: Driver={SQLite3};Database=./tests/odbc/sqlite.db

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- remove discontinued async-std runtime support and async-std-only runtime/TLS dependencies
1010
- remove unmaintained paste dependency from test and Any helper macros
1111
- replace rustls-pemfile with rustls pki-types PEM parsing
12+
- add TLS-oriented feature names (`native-tls`, `rustls`, `rustls-nocrypto`) while keeping legacy runtime feature names as aliases
1213

1314
## 0.6.54
1415
- odbc: improve prepared statement metadata handling and keep execution working when drivers defer result column metadata until bind/execute

Cargo.toml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ authors = [
4343
]
4444

4545
[package.metadata.docs.rs]
46-
features = ["all", "runtime-tokio-native-tls"]
46+
features = ["all", "native-tls"]
4747
rustdoc-args = ["--cfg", "docsrs"]
4848

4949
[features]
@@ -75,42 +75,35 @@ all-types = [
7575
"git2",
7676
]
7777

78-
# previous runtimes, available as features for error messages better than just
79-
# "feature doesn't exist"
80-
runtime-actix = []
81-
runtime-tokio = []
82-
83-
# actual runtimes
84-
runtime-actix-native-tls = ["runtime-tokio-native-tls"]
85-
runtime-tokio-native-tls = [
86-
"sqlx-core/runtime-tokio-native-tls",
87-
"sqlx-macros/runtime-tokio-native-tls",
88-
"_rt-tokio",
78+
# TLS backends. Tokio is the supported async runtime.
79+
native-tls = [
80+
"sqlx-core/native-tls",
81+
"sqlx-macros/native-tls",
8982
]
9083

91-
runtime-actix-rustls = ["runtime-tokio-rustls"]
92-
runtime-tokio-rustls = [
93-
"sqlx-core/runtime-tokio-rustls",
94-
"sqlx-macros/runtime-tokio-rustls",
95-
"sqlx-rt/runtime-tokio-rustls",
84+
rustls = [
85+
"sqlx-core/rustls",
86+
"sqlx-macros/rustls",
87+
"sqlx-rt/rustls",
9688
"aws_lc_rs",
9789
"tls12",
98-
"_rt-tokio",
9990
]
100-
runtime-tokio-rustls-nocrypto = [
101-
"sqlx-core/runtime-tokio-rustls",
102-
"sqlx-macros/runtime-tokio-rustls",
103-
"sqlx-rt/runtime-tokio-rustls",
104-
"_rt-tokio",
91+
rustls-nocrypto = [
92+
"sqlx-core/rustls",
93+
"sqlx-macros/rustls",
94+
"sqlx-rt/rustls",
10595
]
10696

97+
# Backward-compatible aliases for legacy runtime feature names.
98+
runtime-actix-native-tls = ["native-tls"]
99+
runtime-tokio-native-tls = ["native-tls"]
100+
runtime-actix-rustls = ["rustls"]
101+
runtime-tokio-rustls = ["rustls"]
102+
runtime-tokio-rustls-nocrypto = ["rustls-nocrypto"]
103+
107104
aws_lc_rs = ["sqlx-core/aws_lc_rs"]
108105
tls12 = ["sqlx-core/tls12"]
109106

110-
# for conditional compilation
111-
_rt-tokio = []
112-
_rt-actix = []
113-
114107
# database
115108
any = ["sqlx-core/any"]
116109
postgres = ["sqlx-core/postgres", "sqlx-macros/postgres"]

README.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ SQLx is an async, pure Rust<sub>†</sub> SQL crate featuring compile-time check
8282

8383
- **Pure Rust**. The Postgres and MySQL/MariaDB drivers are written in pure Rust using **zero** unsafe<sub>††</sub> code.
8484

85-
- **Runtime Agnostic**. Works on different runtimes ([`tokio`] / [`actix`]) and TLS backends ([`native-tls`], [`rustls`]).
85+
- **Tokio-based**. Uses [`tokio`] for async IO and supports multiple TLS backends ([`native-tls`], [`rustls`]).
8686

8787
<small><small>
8888

@@ -124,31 +124,26 @@ with C, those interactions are `unsafe`.
124124

125125
## Install
126126

127-
SQLx is compatible with the [`tokio`] and [`actix`] runtimes; and, the [`native-tls`] and [`rustls`] TLS backends. When adding the dependency, you must chose a runtime feature that is `runtime` + `tls`.
127+
SQLx uses [`tokio`] for async IO and supports the [`native-tls`] and [`rustls`] TLS backends. When adding the dependency, choose one TLS backend feature.
128128

129129
[`tokio`]: https://github.com/tokio-rs/tokio
130-
[`actix`]: https://github.com/actix/actix-net
131130
[`native-tls`]: https://crates.io/crates/native-tls
132131
[`rustls`]: https://crates.io/crates/rustls
133132

134133
```toml
135134
# Cargo.toml
136135
[dependencies]
137-
# tokio + rustls
138-
sqlx-oldapi = { version = "0.6", features = [ "runtime-tokio-rustls" ] }
136+
# rustls
137+
sqlx-oldapi = { version = "0.6", features = [ "rustls" ] }
139138
```
140139

141-
<small><small>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).</small></small>
142-
143140
#### Cargo Feature Flags
144141

145-
- `runtime-tokio-native-tls`: Use the `tokio` runtime and `native-tls` TLS backend.
146-
147-
- `runtime-tokio-rustls`: Use the `tokio` runtime and `rustls` TLS backend.
142+
- `native-tls`: Use the `native-tls` TLS backend.
148143

149-
- `runtime-actix-native-tls`: Use the `actix` runtime and `native-tls` TLS backend.
144+
- `rustls`: Use the `rustls` TLS backend with the default crypto provider.
150145

151-
- `runtime-actix-rustls`: Use the `actix` runtime and `rustls` TLS backend.
146+
- `rustls-nocrypto`: Use the `rustls` TLS backend without selecting a crypto provider.
152147

153148
- `postgres`: Add support for the Postgres database server.
154149

@@ -217,14 +212,8 @@ See the `examples/` folder for more in-depth usage.
217212

218213
```toml
219214
[dependencies]
220-
# PICK ONE:
221-
# Tokio:
222-
sqlx-oldapi = { version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres" ] }
215+
sqlx-oldapi = { version = "0.6", features = [ "native-tls" , "postgres" ] }
223216
tokio = { version = "1", features = ["full"] }
224-
225-
# Actix-web:
226-
sqlx-oldapi = { version = "0.6", features = [ "runtime-actix-native-tls" , "postgres" ] }
227-
actix-web = "4"
228217
```
229218

230219
```rust

contrib/ide/vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"macros",
77
"migrate",
88
"all-types",
9-
"runtime-actix-rustls"
9+
"rustls"
1010
],
1111
"rust-analyzer.linkedProjects": [
1212
"./Cargo.toml",

examples/mysql/todos/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ workspace = "../../../"
88
[dependencies]
99
anyhow = "1.0"
1010
futures = "0.3"
11-
sqlx = { package = "sqlx-oldapi", path = "../../../", features = [ "mysql", "runtime-tokio-native-tls" ] }
11+
sqlx = { package = "sqlx-oldapi", path = "../../../", features = [ "mysql", "native-tls" ] }
1212
clap = { version = "4.5", features = ["derive"] }
1313
tokio = { version = "1.20.0", features = ["macros"]}

examples/postgres/axum-social-with-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99
[dependencies]
1010
# Primary crates
1111
axum = { version = "0.8", features = ["macros"] }
12-
sqlx = { package = "sqlx-oldapi", version = "0.6.55", path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] }
12+
sqlx = { package = "sqlx-oldapi", version = "0.6.55", path = "../../../", features = ["rustls", "postgres", "time", "uuid"] }
1313
tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros", "net"] }
1414

1515
# Important secondary crates

examples/postgres/files/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ publish = false
88

99
[dependencies]
1010
anyhow = "1.0"
11-
sqlx = { package = "sqlx-oldapi", path = "../../../", features = ["postgres", "offline", "runtime-tokio-native-tls"] }
11+
sqlx = { package = "sqlx-oldapi", path = "../../../", features = ["postgres", "offline", "native-tls"] }
1212
tokio = { version = "1.20.0", features = ["macros"]}
1313
dotenvy = "0.15.0"

examples/postgres/listen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ publish = false
66
workspace = "../../../"
77

88
[dependencies]
9-
sqlx = { package = "sqlx-oldapi", path = "../../../", features = [ "postgres", "tls", "runtime-tokio-native-tls" ] }
9+
sqlx = { package = "sqlx-oldapi", path = "../../../", features = [ "postgres", "tls", "native-tls" ] }
1010
futures = "0.3.1"
1111
tokio = { version = "1.20.0", features = ["macros", "rt-multi-thread", "time"]}

0 commit comments

Comments
 (0)