Skip to content

Commit 99087b7

Browse files
committed
Remove runtime feature keeping the WASM support intact
1 parent 776b59f commit 99087b7

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
- Add WASM support
13+
1214
## [0.12.0] - 2024-05-04
1315

1416
- Add `Send` to `Manager::Type` and `Manager::Error` associated types

postgres/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
- Add WASM support
13+
- Expose API for providing a custom `Connect` implementation.
14+
1215
## [0.13.1] - 2024-05-04
1316

1417
- Update `deadpool` dependency to version `0.12`

postgres/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ readme = "README.md"
1414
all-features = true
1515

1616
[features]
17-
default = ["runtime", "rt_tokio_1"]
18-
runtime = ["tokio-postgres/runtime"]
17+
default = ["rt_tokio_1"]
1918
rt_tokio_1 = ["deadpool/rt_tokio_1"]
2019
rt_async-std_1 = ["deadpool/rt_async-std_1"]
2120
serde = ["deadpool/serde", "dep:serde"]
@@ -28,11 +27,14 @@ serde = { package = "serde", version = "1.0", features = [
2827
"derive",
2928
], optional = true }
3029
tokio = { version = "1.29", features = ["rt"] }
31-
tokio-postgres = { version = "0.7.9", default-features = false }
3230
tracing = "0.1.37"
3331

32+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
33+
tokio-postgres = "0.7.9"
34+
3435
[target.'cfg(target_arch = "wasm32")'.dependencies]
3536
getrandom = { version = "0.2", features = ["js"] }
37+
tokio-postgres = { version = "0.7.9", default-features = false }
3638

3739
[dev-dependencies]
3840
config = { version = "0.14", features = ["json"] }

postgres/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use tokio_postgres::config::{
77
SslMode as PgSslMode, TargetSessionAttrs as PgTargetSessionAttrs,
88
};
99

10-
#[cfg(feature = "runtime")]
10+
#[cfg(not(target_arch = "wasm32"))]
1111
use super::Pool;
12-
#[cfg(feature = "runtime")]
12+
#[cfg(not(target_arch = "wasm32"))]
1313
use crate::{CreatePoolError, PoolBuilder, Runtime};
14-
#[cfg(feature = "runtime")]
14+
#[cfg(not(target_arch = "wasm32"))]
1515
use tokio_postgres::{
1616
tls::{MakeTlsConnect, TlsConnect},
1717
Socket,
@@ -151,7 +151,7 @@ impl Config {
151151
Self::default()
152152
}
153153

154-
#[cfg(feature = "runtime")]
154+
#[cfg(not(target_arch = "wasm32"))]
155155
/// Creates a new [`Pool`] using this [`Config`].
156156
///
157157
/// # Errors
@@ -171,7 +171,7 @@ impl Config {
171171
builder.build().map_err(CreatePoolError::Build)
172172
}
173173

174-
#[cfg(feature = "runtime")]
174+
#[cfg(not(target_arch = "wasm32"))]
175175
/// Creates a new [`PoolBuilder`] using this [`Config`].
176176
///
177177
/// # Errors

postgres/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ use std::{
3737
};
3838

3939
use deadpool::managed;
40-
#[cfg(feature = "runtime")]
40+
#[cfg(not(target_arch = "wasm32"))]
4141
use tokio::spawn;
4242
use tokio::task::JoinHandle;
4343
use tokio_postgres::{
4444
types::Type, Client as PgClient, Config as PgConfig, Error, IsolationLevel, Statement,
4545
Transaction as PgTransaction, TransactionBuilder as PgTransactionBuilder,
4646
};
4747

48-
#[cfg(feature = "runtime")]
48+
#[cfg(not(target_arch = "wasm32"))]
4949
use tokio_postgres::{
5050
tls::{MakeTlsConnect, TlsConnect},
5151
Socket,
@@ -89,7 +89,7 @@ pub struct Manager {
8989
}
9090

9191
impl Manager {
92-
#[cfg(feature = "runtime")]
92+
#[cfg(not(target_arch = "wasm32"))]
9393
/// Creates a new [`Manager`] using the given [`tokio_postgres::Config`] and
9494
/// `tls` connector.
9595
pub fn new<T>(pg_config: tokio_postgres::Config, tls: T) -> Self
@@ -102,7 +102,7 @@ impl Manager {
102102
Self::from_config(pg_config, tls, ManagerConfig::default())
103103
}
104104

105-
#[cfg(feature = "runtime")]
105+
#[cfg(not(target_arch = "wasm32"))]
106106
/// Create a new [`Manager`] using the given [`tokio_postgres::Config`], and
107107
/// `tls` connector and [`ManagerConfig`].
108108
pub fn from_config<T>(pg_config: tokio_postgres::Config, tls: T, config: ManagerConfig) -> Self
@@ -188,7 +188,7 @@ pub trait Connect: Sync + Send {
188188
) -> BoxFuture<'_, Result<(PgClient, JoinHandle<()>), Error>>;
189189
}
190190

191-
#[cfg(feature = "runtime")]
191+
#[cfg(not(target_arch = "wasm32"))]
192192
/// Provides an implementation of [`Connect`] that establishes the connection
193193
/// using the `tokio_postgres` configuration itself.
194194
#[derive(Debug)]
@@ -203,7 +203,7 @@ where
203203
pub tls: T,
204204
}
205205

206-
#[cfg(feature = "runtime")]
206+
#[cfg(not(target_arch = "wasm32"))]
207207
impl<T> Connect for ConfigConnectImpl<T>
208208
where
209209
T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy