Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3fc804e

Browse files
committed
Support build on wasm32
Signed-off-by: csh <458761603@qq.com>
1 parent98f5a11 commit3fc804e

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

‎tokio-postgres/src/cancel_query.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ where
3434
config.port,
3535
config.connect_timeout,
3636
config.tcp_user_timeout,
37+
#[cfg(not(target_arch ="wasm32"))]
3738
config.keepalive.as_ref(),
3839
)
3940
.await?;

‎tokio-postgres/src/client.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::codec::{BackendMessages, FrontendMessage};
22
usecrate::config::SslMode;
33
usecrate::connection::{Request,RequestMessages};
44
usecrate::copy_out::CopyOutStream;
5-
#[cfg(feature ="runtime")]
5+
#[cfg(all(feature ="runtime", not(target_arch ="wasm32")))]
66
usecrate::keepalive::KeepaliveConfig;
77
usecrate::query::RowStream;
88
usecrate::simple_query::SimpleQueryStream;
@@ -27,7 +27,7 @@ use std::collections::HashMap;
2727
use std::fmt;
2828
#[cfg(feature ="runtime")]
2929
use std::net::IpAddr;
30-
#[cfg(feature ="runtime")]
30+
#[cfg(all(feature ="runtime", unix))]
3131
use std::path::PathBuf;
3232
use std::sync::Arc;
3333
use std::task::{Context,Poll};
@@ -160,6 +160,7 @@ pub(crate) struct SocketConfig {
160160
pubport:u16,
161161
pubconnect_timeout:Option<Duration>,
162162
pubtcp_user_timeout:Option<Duration>,
163+
#[cfg(not(target_arch ="wasm32"))]
163164
pubkeepalive:Option<KeepaliveConfig>,
164165
}
165166

‎tokio-postgres/src/connect.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ where
146146
port,
147147
config.connect_timeout,
148148
config.tcp_user_timeout,
149+
#[cfg(not(target_arch ="wasm32"))]
149150
if config.keepalives{
150151
Some(&config.keepalive_config)
151152
}else{
@@ -216,6 +217,7 @@ where
216217
port,
217218
connect_timeout: config.connect_timeout,
218219
tcp_user_timeout: config.tcp_user_timeout,
220+
#[cfg(not(target_arch ="wasm32"))]
219221
keepalive:if config.keepalives{
220222
Some(config.keepalive_config.clone())
221223
}else{

‎tokio-postgres/src/connect_socket.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
usecrate::client::Addr;
2+
#[cfg(not(target_arch ="wasm32"))]
23
usecrate::keepalive::KeepaliveConfig;
34
usecrate::{Error,Socket};
5+
#[cfg(not(target_arch ="wasm32"))]
46
use socket2::{SockRef,TcpKeepalive};
57
use std::future::Future;
68
use std::io;
@@ -17,7 +19,7 @@ pub(crate) async fn connect_socket(
1719
#[cfg_attr(not(target_os ="linux"), allow(unused_variables))]tcp_user_timeout:Option<
1820
Duration,
1921
>,
20-
keepalive_config:Option<&KeepaliveConfig>,
22+
#[cfg(not(target_arch ="wasm32"))]keepalive_config:Option<&KeepaliveConfig>,
2123
) ->Result<Socket,Error>{
2224
match addr{
2325
Addr::Tcp(ip) =>{
@@ -26,6 +28,7 @@ pub(crate) async fn connect_socket(
2628

2729
stream.set_nodelay(true).map_err(Error::connect)?;
2830

31+
#[cfg(not(target_arch ="wasm32"))]
2932
let sock_ref =SockRef::from(&stream);
3033
#[cfg(target_os ="linux")]
3134
{
@@ -34,6 +37,7 @@ pub(crate) async fn connect_socket(
3437
.map_err(Error::connect)?;
3538
}
3639

40+
#[cfg(not(target_arch ="wasm32"))]
3741
ifletSome(keepalive_config) = keepalive_config{
3842
sock_ref
3943
.set_tcp_keepalive(&TcpKeepalive::from(keepalive_config))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp