Skip to content

Commit 7ca7a20

Browse files
committed
Enable r2d2 feature for diesel and clarify error types
Added the 'r2d2' feature to the diesel dependency in rustapi-extras to ensure r2d2 integration is available. Updated error handling in DieselPoolBuilder to explicitly use r2d2::Error, improving type clarity.
1 parent b091011 commit 7ca7a20

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustapi-extras/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dashmap = { version = "6.0", optional = true }
4141
sqlx = { version = "0.8", optional = true, default-features = false }
4242

4343
# Diesel (feature-gated)
44-
diesel = { version = "2.2", optional = true, default-features = false }
44+
diesel = { version = "2.2", optional = true, default-features = false, features = ["r2d2"] }
4545
r2d2 = { version = "0.8", optional = true }
4646

4747
# Configuration (feature-gated)

crates/rustapi-extras/src/diesel/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl DieselPoolBuilder {
217217

218218
builder
219219
.build(manager)
220-
.map_err(|e| DieselPoolError::Pool(e.to_string()))
220+
.map_err(|e: r2d2::Error| DieselPoolError::Pool(e.to_string()))
221221
}
222222

223223
/// Build a MySQL connection pool
@@ -255,7 +255,7 @@ impl DieselPoolBuilder {
255255

256256
builder
257257
.build(manager)
258-
.map_err(|e| DieselPoolError::Pool(e.to_string()))
258+
.map_err(|e: r2d2::Error| DieselPoolError::Pool(e.to_string()))
259259
}
260260

261261
/// Build a SQLite connection pool
@@ -295,7 +295,7 @@ impl DieselPoolBuilder {
295295

296296
builder
297297
.build(manager)
298-
.map_err(|e| DieselPoolError::Pool(e.to_string()))
298+
.map_err(|e: r2d2::Error| DieselPoolError::Pool(e.to_string()))
299299
}
300300

301301
/// Create a health check for a PostgreSQL pool

0 commit comments

Comments
 (0)