From d3ebb5172d97fd8e76192d93a1b811e80fdda784 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Thu, 8 Aug 2024 21:52:50 +0530 Subject: [PATCH 1/4] fix: on `AsyncReadWrite` enforce `Sync` --- rumqttc/src/framed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rumqttc/src/framed.rs b/rumqttc/src/framed.rs index beb1d32de..ec0e6ba6d 100644 --- a/rumqttc/src/framed.rs +++ b/rumqttc/src/framed.rs @@ -92,5 +92,5 @@ impl Network { } } -pub trait AsyncReadWrite: AsyncRead + AsyncWrite + Send + Unpin {} -impl AsyncReadWrite for T where T: AsyncRead + AsyncWrite + Send + Unpin {} +pub trait AsyncReadWrite: AsyncRead + AsyncWrite + Send + Sync + Unpin {} +impl AsyncReadWrite for T where T: AsyncRead + AsyncWrite + Send + Sync + Unpin {} From a0bcf620c29443fac91af79aa151fb6cd16208a5 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 9 Aug 2024 09:33:39 +0530 Subject: [PATCH 2/4] fix: enable sync only for builds without websocket support --- rumqttc/src/framed.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rumqttc/src/framed.rs b/rumqttc/src/framed.rs index ec0e6ba6d..ef86382d6 100644 --- a/rumqttc/src/framed.rs +++ b/rumqttc/src/framed.rs @@ -92,5 +92,11 @@ impl Network { } } +#[cfg(not(feature = "websocket"))] pub trait AsyncReadWrite: AsyncRead + AsyncWrite + Send + Sync + Unpin {} +#[cfg(not(feature = "websocket"))] impl AsyncReadWrite for T where T: AsyncRead + AsyncWrite + Send + Sync + Unpin {} +#[cfg(feature = "websocket")] +pub trait AsyncReadWrite: AsyncRead + AsyncWrite + Send + Unpin {} +#[cfg(feature = "websocket")] +impl AsyncReadWrite for T where T: AsyncRead + AsyncWrite + Send + Unpin {} From f62db1ed4be07e3d7f4d58955bfabe3af79cd039 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 9 Aug 2024 09:33:48 +0530 Subject: [PATCH 3/4] doc: changelog --- rumqttc/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rumqttc/CHANGELOG.md b/rumqttc/CHANGELOG.md index c8c8716a3..f1707c9bb 100644 --- a/rumqttc/CHANGELOG.md +++ b/rumqttc/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Made `DisconnectProperties` struct public. * Replace `Vec>` with `FixedBitSet` for managing packet ids of released QoS 2 publishes and incoming QoS 2 publishes in `MqttState`. * Accept `native_tls::TlsConnector` as input for `Transport::tls_with_config`. +* Enforce `Sync` for `AsyncReadWrite` ### Deprecated From c00f773b5e64fa63a471c64f4b7fd45a9be60d12 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 9 Aug 2024 09:50:41 +0530 Subject: [PATCH 4/4] doc: note for sync incompatability --- rumqttc/src/framed.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rumqttc/src/framed.rs b/rumqttc/src/framed.rs index ef86382d6..2b5b34d02 100644 --- a/rumqttc/src/framed.rs +++ b/rumqttc/src/framed.rs @@ -92,6 +92,8 @@ impl Network { } } +// NOTE: WsStream currently doesn't support Sync, so we disable Sync enforcement for websocket builds + #[cfg(not(feature = "websocket"))] pub trait AsyncReadWrite: AsyncRead + AsyncWrite + Send + Sync + Unpin {} #[cfg(not(feature = "websocket"))]