diff --git a/Cargo.lock b/Cargo.lock index 915b47d253b..8c80f0b50a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.6" +version = "0.43.7" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index 7194347e1e6..26387938e75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -101,7 +101,7 @@ libp2p-rendezvous = { version = "0.13.1", path = "protocols/rendezvous" } libp2p-upnp = { version = "0.1.1", path = "protocols/upnp" } libp2p-request-response = { version = "0.25.2", path = "protocols/request-response" } libp2p-server = { version = "0.12.3", path = "misc/server" } -libp2p-swarm = { version = "0.43.6", path = "swarm" } +libp2p-swarm = { version = "0.43.7", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } libp2p-tcp = { version = "0.40.1", path = "transports/tcp" } diff --git a/misc/metrics/src/swarm.rs b/misc/metrics/src/swarm.rs index 8837457d36a..47e8d69006d 100644 --- a/misc/metrics/src/swarm.rs +++ b/misc/metrics/src/swarm.rs @@ -325,6 +325,7 @@ impl From<&libp2p_swarm::ConnectionError> for ConnectionError { match value { libp2p_swarm::ConnectionError::IO(_) => ConnectionError::Io, libp2p_swarm::ConnectionError::KeepAliveTimeout => ConnectionError::KeepAliveTimeout, + #[allow(deprecated)] libp2p_swarm::ConnectionError::Handler(_) => ConnectionError::Handler, } } diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index ff22f2b18e1..21ddc6c868a 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -69,6 +69,7 @@ pub struct Handler { >, >, /// Queue of events to return when polled. + #[allow(deprecated)] queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, @@ -268,6 +269,7 @@ impl ConnectionHandler for Handler { KeepAlive::No } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -282,6 +284,7 @@ impl ConnectionHandler for Handler { // Check for a pending (fatal) error. if let Some(err) = self.pending_error.take() { // The handler will not be polled again by the `Swarm`. + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(err)); } @@ -298,7 +301,9 @@ impl ConnectionHandler for Handler { Event::InboundConnectNegotiated(addresses), )); } - Err(e) => { + Err(e) => + { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Apply( Either::Left(e), ))) diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index f152b51ba14..c7004372c82 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -218,6 +218,7 @@ impl EnabledHandler { self.outbound_substream = Some(OutboundSubstreamState::WaitingOutput(substream)); } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -451,6 +452,7 @@ impl ConnectionHandler for Handler { } } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/protocols/identify/src/handler.rs b/protocols/identify/src/handler.rs index 50b9882f2c5..81f1a8b2bf1 100644 --- a/protocols/identify/src/handler.rs +++ b/protocols/identify/src/handler.rs @@ -322,6 +322,7 @@ impl ConnectionHandler for Handler { KeepAlive::No } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index fdb927836c7..7b85dae9247 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -721,6 +721,7 @@ impl ConnectionHandler for Handler { self.keep_alive } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index 522663196e6..59a3787e18d 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -229,6 +229,7 @@ impl ConnectionHandler for Handler { KeepAlive::No } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index fc822e78ce5..684e3394251 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -339,6 +339,7 @@ pub struct Handler { config: Config, /// Queue of events to return when polled. + #[allow(deprecated)] queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, @@ -619,6 +620,7 @@ impl ConnectionHandler for Handler { self.keep_alive } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -633,6 +635,7 @@ impl ConnectionHandler for Handler { // Check for a pending (fatal) error. if let Some(err) = self.pending_error.take() { // The handler will not be polled again by the `Swarm`. + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(err)); } @@ -712,14 +715,17 @@ impl ConnectionHandler for Handler { )); } Poll::Ready(Err(futures_bounded::Timeout { .. })) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Timeout)); } Poll::Ready(Ok(Either::Left(Err(e)))) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Apply( Either::Left(e), ))); } Poll::Ready(Ok(Either::Right(Err(e)))) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Apply( Either::Right(e), ))); diff --git a/protocols/relay/src/priv_client/handler.rs b/protocols/relay/src/priv_client/handler.rs index 41ac85cfdd2..529511aed1e 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -126,6 +126,7 @@ pub struct Handler { keep_alive: KeepAlive, /// Queue of events to return when polled. + #[allow(deprecated)] queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, @@ -331,6 +332,7 @@ impl ConnectionHandler for Handler { self.keep_alive } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -345,6 +347,7 @@ impl ConnectionHandler for Handler { // Check for a pending (fatal) error. if let Some(err) = self.pending_error.take() { // The handler will not be polled again by the `Swarm`. + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(err)); } @@ -389,12 +392,15 @@ impl ConnectionHandler for Handler { }, )); } - Poll::Ready(Ok(Err(e))) => { + Poll::Ready(Ok(Err(e))) => + { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Apply( Either::Right(e), ))) } Poll::Ready(Err(Timeout { .. })) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Timeout)); } Poll::Pending => break, @@ -410,6 +416,7 @@ impl ConnectionHandler for Handler { let res = match worker_res { Ok(r) => r, Err(Timeout { .. }) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Timeout)); } }; @@ -442,6 +449,7 @@ impl ConnectionHandler for Handler { } }, Err(e) => { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(StreamUpgradeError::Apply( Either::Left(e), ))); diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index 86f036365b8..54a467b331e 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -288,6 +288,7 @@ where self.keep_alive } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/swarm-test/src/lib.rs b/swarm-test/src/lib.rs index 41a606b300c..28605c65a55 100644 --- a/swarm-test/src/lib.rs +++ b/swarm-test/src/lib.rs @@ -27,9 +27,9 @@ use libp2p_core::{ use libp2p_identity::{Keypair, PeerId}; use libp2p_plaintext as plaintext; use libp2p_swarm::dial_opts::PeerCondition; -use libp2p_swarm::{ - self as swarm, dial_opts::DialOpts, NetworkBehaviour, Swarm, SwarmEvent, THandlerErr, -}; +#[allow(deprecated)] +use libp2p_swarm::THandlerErr; +use libp2p_swarm::{self as swarm, dial_opts::DialOpts, NetworkBehaviour, Swarm, SwarmEvent}; use libp2p_yamux as yamux; use std::fmt::Debug; use std::time::Duration; @@ -63,6 +63,7 @@ pub trait SwarmExt { async fn dial_and_wait(&mut self, addr: Multiaddr) -> PeerId; /// Wait for specified condition to return `Some`. + #[allow(deprecated)] async fn wait(&mut self, predicate: P) -> E where P: Fn( @@ -78,6 +79,7 @@ pub trait SwarmExt { /// Returns the next [`SwarmEvent`] or times out after 10 seconds. /// /// If the 10s timeout does not fit your usecase, please fall back to `StreamExt::next`. + #[allow(deprecated)] async fn next_swarm_event( &mut self, ) -> SwarmEvent<::ToSwarm, THandlerErr>; @@ -121,6 +123,7 @@ pub trait SwarmExt { /// This can "starve" the other swarm which for example may wait for another message to be sent on a connection. /// /// Using [`drive`] instead of [`futures::future::join`] ensures that a [`Swarm`] continues to be polled, even after it emitted its events. +#[allow(deprecated)] pub async fn drive< TBehaviour1, const NUM_EVENTS_SWARM_1: usize, @@ -279,6 +282,7 @@ where .await } + #[allow(deprecated)] async fn wait(&mut self, predicate: P) -> E where P: Fn(SwarmEvent<::ToSwarm, THandlerErr>) -> Option, @@ -341,6 +345,7 @@ where (memory_multiaddr, tcp_multiaddr) } + #[allow(deprecated)] async fn next_swarm_event( &mut self, ) -> SwarmEvent<::ToSwarm, THandlerErr> { diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index b1ecd2f6479..90e1431be9c 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.43.7 + +- Deprecate `ConnectionHandlerEvent::Close`. + See [issue 3591](https://github.com/libp2p/rust-libp2p/issues/3591) for details. + See [PR 4714](https://github.com/libp2p/rust-libp2p/pull/4714). + ## 0.43.6 - Deprecate `libp2p::swarm::SwarmBuilder`. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index d151e7af614..517657fd745 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.43.6" +version = "0.43.7" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/src/behaviour/toggle.rs b/swarm/src/behaviour/toggle.rs index 92bd8963502..80d94e539d2 100644 --- a/swarm/src/behaviour/toggle.rs +++ b/swarm/src/behaviour/toggle.rs @@ -269,6 +269,7 @@ where { type FromBehaviour = TInner::FromBehaviour; type ToBehaviour = TInner::ToBehaviour; + #[allow(deprecated)] type Error = TInner::Error; type InboundProtocol = Either, SendWrapper>; type OutboundProtocol = TInner::OutboundProtocol; @@ -300,6 +301,7 @@ where .unwrap_or(KeepAlive::No) } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index a9c56c80d63..b45091ba99c 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -221,6 +221,7 @@ where /// Polls the handler and the substream, forwarding events from the former to the latter and /// vice versa. + #[allow(deprecated)] pub(crate) fn poll( self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -267,6 +268,7 @@ where Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) => { return Poll::Ready(Ok(Event::Handler(event))); } + #[allow(deprecated)] Poll::Ready(ConnectionHandlerEvent::Close(err)) => { return Poll::Ready(Err(ConnectionError::Handler(err))); } @@ -429,6 +431,7 @@ where } #[cfg(test)] + #[allow(deprecated)] fn poll_noop_waker( &mut self, ) -> Poll, ConnectionError>> { @@ -1082,6 +1085,7 @@ mod tests { KeepAlive::Until(self.until) } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, @@ -1312,6 +1316,7 @@ mod tests { KeepAlive::Yes } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, @@ -1389,6 +1394,7 @@ mod tests { KeepAlive::Yes } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, diff --git a/swarm/src/connection/error.rs b/swarm/src/connection/error.rs index 5d5dda57868..74a3a107c12 100644 --- a/swarm/src/connection/error.rs +++ b/swarm/src/connection/error.rs @@ -34,6 +34,9 @@ pub enum ConnectionError { KeepAliveTimeout, /// The connection handler produced an error. + #[deprecated( + note = "Will be removed together with `ConnectionHandlerEvent::Close`. See for details." + )] Handler(THandlerErr), } @@ -47,6 +50,7 @@ where ConnectionError::KeepAliveTimeout => { write!(f, "Connection closed due to expired keep-alive timeout.") } + #[allow(deprecated)] ConnectionError::Handler(err) => write!(f, "Connection error: Handler error: {err}"), } } @@ -60,6 +64,7 @@ where match self { ConnectionError::IO(err) => Some(err), ConnectionError::KeepAliveTimeout => None, + #[allow(deprecated)] ConnectionError::Handler(err) => Some(err), } } diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index b6100989a04..5a41f3bea46 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -225,6 +225,7 @@ impl fmt::Debug for Pool { /// Event that can happen on the `Pool`. #[derive(Debug)] +#[allow(deprecated)] pub(crate) enum PoolEvent { /// A new connection has been established. ConnectionEstablished { diff --git a/swarm/src/connection/pool/task.rs b/swarm/src/connection/pool/task.rs index 175da668bda..aa5c934bbe3 100644 --- a/swarm/src/connection/pool/task.rs +++ b/swarm/src/connection/pool/task.rs @@ -66,6 +66,7 @@ pub(crate) enum PendingConnectionEvent { } #[derive(Debug)] +#[allow(deprecated)] pub(crate) enum EstablishedConnectionEvent { /// A node we are connected to has changed its address. AddressChange { diff --git a/swarm/src/dummy.rs b/swarm/src/dummy.rs index 6810abec591..f7e8bad9171 100644 --- a/swarm/src/dummy.rs +++ b/swarm/src/dummy.rs @@ -102,6 +102,7 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { KeepAlive::No } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index 02eb9f83935..07b83092efa 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -104,6 +104,9 @@ pub trait ConnectionHandler: Send + 'static { /// A type representing message(s) a [`ConnectionHandler`] can send to a [`NetworkBehaviour`](crate::behaviour::NetworkBehaviour) via [`ConnectionHandlerEvent::NotifyBehaviour`]. type ToBehaviour: fmt::Debug + Send + 'static; /// The type of errors returned by [`ConnectionHandler::poll`]. + #[deprecated( + note = "Will be removed together with `ConnectionHandlerEvent::Close`. See for details." + )] type Error: error::Error + fmt::Debug + Send + 'static; /// The inbound upgrade for the protocol(s) used by the handler. type InboundProtocol: InboundUpgradeSend; @@ -146,6 +149,7 @@ pub trait ConnectionHandler: Send + 'static { fn connection_keep_alive(&self) -> KeepAlive; /// Should behave like `Stream::poll()`. + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -545,6 +549,9 @@ pub enum ConnectionHandlerEvent ConnectionHandlerEvent::NotifyBehaviour(val) => { ConnectionHandlerEvent::NotifyBehaviour(val) } + #[allow(deprecated)] ConnectionHandlerEvent::Close(val) => ConnectionHandlerEvent::Close(val), ConnectionHandlerEvent::ReportRemoteProtocols(support) => { ConnectionHandlerEvent::ReportRemoteProtocols(support) @@ -608,6 +616,7 @@ impl ConnectionHandlerEvent::NotifyBehaviour(val) => { ConnectionHandlerEvent::NotifyBehaviour(val) } + #[allow(deprecated)] ConnectionHandlerEvent::Close(val) => ConnectionHandlerEvent::Close(val), ConnectionHandlerEvent::ReportRemoteProtocols(support) => { ConnectionHandlerEvent::ReportRemoteProtocols(support) @@ -630,6 +639,7 @@ impl ConnectionHandlerEvent::NotifyBehaviour(val) => { ConnectionHandlerEvent::NotifyBehaviour(map(val)) } + #[allow(deprecated)] ConnectionHandlerEvent::Close(val) => ConnectionHandlerEvent::Close(val), ConnectionHandlerEvent::ReportRemoteProtocols(support) => { ConnectionHandlerEvent::ReportRemoteProtocols(support) @@ -652,6 +662,7 @@ impl ConnectionHandlerEvent::NotifyBehaviour(val) => { ConnectionHandlerEvent::NotifyBehaviour(val) } + #[allow(deprecated)] ConnectionHandlerEvent::Close(val) => ConnectionHandlerEvent::Close(map(val)), ConnectionHandlerEvent::ReportRemoteProtocols(support) => { ConnectionHandlerEvent::ReportRemoteProtocols(support) diff --git a/swarm/src/handler/either.rs b/swarm/src/handler/either.rs index 6a60427228d..f66c849abff 100644 --- a/swarm/src/handler/either.rs +++ b/swarm/src/handler/either.rs @@ -80,6 +80,7 @@ where { type FromBehaviour = Either; type ToBehaviour = Either; + #[allow(deprecated)] type Error = Either; type InboundProtocol = Either, SendWrapper>; type OutboundProtocol = @@ -115,6 +116,7 @@ where } } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/swarm/src/handler/map_in.rs b/swarm/src/handler/map_in.rs index 82cb12a183d..3511dc8cde7 100644 --- a/swarm/src/handler/map_in.rs +++ b/swarm/src/handler/map_in.rs @@ -52,6 +52,7 @@ where { type FromBehaviour = TNewIn; type ToBehaviour = TConnectionHandler::ToBehaviour; + #[allow(deprecated)] type Error = TConnectionHandler::Error; type InboundProtocol = TConnectionHandler::InboundProtocol; type OutboundProtocol = TConnectionHandler::OutboundProtocol; @@ -72,6 +73,7 @@ where self.inner.connection_keep_alive() } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/swarm/src/handler/map_out.rs b/swarm/src/handler/map_out.rs index 8528b563ece..8c0e87e3bd1 100644 --- a/swarm/src/handler/map_out.rs +++ b/swarm/src/handler/map_out.rs @@ -47,6 +47,7 @@ where { type FromBehaviour = TConnectionHandler::FromBehaviour; type ToBehaviour = TNewOut; + #[allow(deprecated)] type Error = TConnectionHandler::Error; type InboundProtocol = TConnectionHandler::InboundProtocol; type OutboundProtocol = TConnectionHandler::OutboundProtocol; @@ -65,6 +66,7 @@ where self.inner.connection_keep_alive() } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -80,6 +82,7 @@ where ConnectionHandlerEvent::NotifyBehaviour(ev) => { ConnectionHandlerEvent::NotifyBehaviour((self.map)(ev)) } + #[allow(deprecated)] ConnectionHandlerEvent::Close(err) => ConnectionHandlerEvent::Close(err), ConnectionHandlerEvent::OutboundSubstreamRequest { protocol } => { ConnectionHandlerEvent::OutboundSubstreamRequest { protocol } diff --git a/swarm/src/handler/multi.rs b/swarm/src/handler/multi.rs index ced94f1213c..7f4a910ae0e 100644 --- a/swarm/src/handler/multi.rs +++ b/swarm/src/handler/multi.rs @@ -112,6 +112,7 @@ where { type FromBehaviour = (K, ::FromBehaviour); type ToBehaviour = (K, ::ToBehaviour); + #[allow(deprecated)] type Error = ::Error; type InboundProtocol = Upgrade::InboundProtocol>; type OutboundProtocol = ::OutboundProtocol; @@ -238,6 +239,7 @@ where .unwrap_or(KeepAlive::No) } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/swarm/src/handler/one_shot.rs b/swarm/src/handler/one_shot.rs index 473aa50798c..4a99cc679df 100644 --- a/swarm/src/handler/one_shot.rs +++ b/swarm/src/handler/one_shot.rs @@ -141,6 +141,7 @@ where self.keep_alive } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, @@ -153,6 +154,7 @@ where >, > { if let Some(err) = self.pending_error.take() { + #[allow(deprecated)] return Poll::Ready(ConnectionHandlerEvent::Close(err)); } diff --git a/swarm/src/handler/pending.rs b/swarm/src/handler/pending.rs index ee6829356bd..e9aa4e088f5 100644 --- a/swarm/src/handler/pending.rs +++ b/swarm/src/handler/pending.rs @@ -60,6 +60,7 @@ impl ConnectionHandler for PendingConnectionHandler { KeepAlive::No } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, diff --git a/swarm/src/handler/select.rs b/swarm/src/handler/select.rs index 65db4ab525b..ddf90a25291 100644 --- a/swarm/src/handler/select.rs +++ b/swarm/src/handler/select.rs @@ -181,6 +181,7 @@ where { type FromBehaviour = Either; type ToBehaviour = Either; + #[allow(deprecated)] type Error = Either; type InboundProtocol = SelectUpgrade< SendWrapper<::InboundProtocol>, @@ -215,6 +216,7 @@ where ) } + #[allow(deprecated)] fn poll( &mut self, cx: &mut Context<'_>, @@ -230,6 +232,7 @@ where Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) => { return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(Either::Left(event))); } + #[allow(deprecated)] Poll::Ready(ConnectionHandlerEvent::Close(event)) => { return Poll::Ready(ConnectionHandlerEvent::Close(Either::Left(event))); } @@ -252,6 +255,7 @@ where event, ))); } + #[allow(deprecated)] Poll::Ready(ConnectionHandlerEvent::Close(event)) => { return Poll::Ready(ConnectionHandlerEvent::Close(Either::Right(event))); } diff --git a/swarm/src/keep_alive.rs b/swarm/src/keep_alive.rs index 05cbcdf7b8c..a32e65ea2f4 100644 --- a/swarm/src/keep_alive.rs +++ b/swarm/src/keep_alive.rs @@ -105,6 +105,7 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { KeepAlive::Yes } + #[allow(deprecated)] fn poll( &mut self, _: &mut Context<'_>, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 52498156f1f..17cdc803c06 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -178,6 +178,10 @@ pub type THandlerInEvent = as ConnectionHandle pub type THandlerOutEvent = as ConnectionHandler>::ToBehaviour; /// Custom error that can be produced by the [`ConnectionHandler`] of the [`NetworkBehaviour`]. +#[deprecated( + note = "Will be removed together with `ConnectionHandlerEvent::Close`. See for details." +)] +#[allow(deprecated)] pub type THandlerErr = as ConnectionHandler>::Error; /// Event generated by the `Swarm`. @@ -670,6 +674,7 @@ where &mut self.behaviour } + #[allow(deprecated)] fn handle_pool_event( &mut self, event: PoolEvent>, @@ -914,6 +919,7 @@ where None } + #[allow(deprecated)] fn handle_transport_event( &mut self, event: TransportEvent< @@ -1045,6 +1051,7 @@ where } } + #[allow(deprecated)] fn handle_behaviour_event( &mut self, event: ToSwarm>, @@ -1146,6 +1153,7 @@ where /// Internal function used by everything event-related. /// /// Polls the `Swarm` for the next event. + #[allow(deprecated)] fn poll_next_event( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -1338,6 +1346,7 @@ impl futures::Stream for Swarm where TBehaviour: NetworkBehaviour, { + #[allow(deprecated)] type Item = SwarmEvent, THandlerErr>; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {