diff --git a/protocols/autonat/src/v2/client/handler/dial_back.rs b/protocols/autonat/src/v2/client/handler/dial_back.rs index ef544a4c77a..7cdf194343a 100644 --- a/protocols/autonat/src/v2/client/handler/dial_back.rs +++ b/protocols/autonat/src/v2/client/handler/dial_back.rs @@ -35,16 +35,14 @@ impl ConnectionHandler for Handler { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(ReadyUpgrade::new(DIAL_BACK_PROTOCOL), ()) } fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { loop { match self.inbound.poll_next_unpin(cx) { Poll::Pending => return Poll::Pending, @@ -68,12 +66,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/protocols/autonat/src/v2/client/handler/dial_request.rs b/protocols/autonat/src/v2/client/handler/dial_request.rs index fff83ad9453..61f564505eb 100644 --- a/protocols/autonat/src/v2/client/handler/dial_request.rs +++ b/protocols/autonat/src/v2/client/handler/dial_request.rs @@ -72,7 +72,7 @@ pub struct Handler { queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, >, @@ -121,16 +121,14 @@ impl ConnectionHandler for Handler { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()) } fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { if let Some(event) = self.queued_events.pop_front() { return Poll::Ready(event); } @@ -161,12 +159,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => { diff --git a/protocols/autonat/src/v2/server/handler/dial_back.rs b/protocols/autonat/src/v2/server/handler/dial_back.rs index 61593da318d..8adb33509ef 100644 --- a/protocols/autonat/src/v2/server/handler/dial_back.rs +++ b/protocols/autonat/src/v2/server/handler/dial_back.rs @@ -46,16 +46,14 @@ impl ConnectionHandler for Handler { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()) } fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { if let Poll::Ready(result) = self.outbound.poll_unpin(cx) { return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( result @@ -76,12 +74,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedOutbound(FullyNegotiatedOutbound { diff --git a/protocols/autonat/src/v2/server/handler/dial_request.rs b/protocols/autonat/src/v2/server/handler/dial_request.rs index 5058e0f3f42..22cab2b9cab 100644 --- a/protocols/autonat/src/v2/server/handler/dial_request.rs +++ b/protocols/autonat/src/v2/server/handler/dial_request.rs @@ -81,16 +81,14 @@ where type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(ReadyUpgrade::new(DIAL_REQUEST_PROTOCOL), ()) } fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { loop { match self.inbound.poll_unpin(cx) { Poll::Ready(Ok(event)) => { @@ -117,12 +115,7 @@ where fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/protocols/dcutr/src/handler/relayed.rs b/protocols/dcutr/src/handler/relayed.rs index 0d6e1b5e889..47813493e9e 100644 --- a/protocols/dcutr/src/handler/relayed.rs +++ b/protocols/dcutr/src/handler/relayed.rs @@ -65,7 +65,7 @@ pub struct Handler { queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, >, @@ -98,10 +98,7 @@ impl Handler { &mut self, FullyNegotiatedInbound { protocol: output, .. - }: FullyNegotiatedInbound< - ::InboundProtocol, - ::InboundOpenInfo, - >, + }: FullyNegotiatedInbound<::InboundProtocol>, ) { match output { future::Either::Left(stream) => { @@ -130,10 +127,7 @@ impl Handler { &mut self, FullyNegotiatedOutbound { protocol: stream, .. - }: FullyNegotiatedOutbound< - ::OutboundProtocol, - ::OutboundOpenInfo, - >, + }: FullyNegotiatedOutbound<::OutboundProtocol>, ) { assert!( self.endpoint.is_listener(), @@ -156,7 +150,7 @@ impl Handler { fn on_listen_upgrade_error( &mut self, ListenUpgradeError { error, .. }: ListenUpgradeError< - ::InboundOpenInfo, + (), ::InboundProtocol, >, ) { @@ -168,7 +162,7 @@ impl Handler { fn on_dial_upgrade_error( &mut self, DialUpgradeError { error, .. }: DialUpgradeError< - ::OutboundOpenInfo, + (), ::OutboundProtocol, >, ) { @@ -196,7 +190,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { match self.endpoint { ConnectedPoint::Dialer { .. } => { SubstreamProtocol::new(Either::Left(ReadyUpgrade::new(PROTOCOL_NAME)), ()) @@ -236,9 +230,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { // Return queued events. if let Some(event) = self.queued_events.pop_front() { return Poll::Ready(event); @@ -295,12 +287,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(fully_negotiated_inbound) => { diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index e66b606896b..f93e993a854 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -198,7 +198,6 @@ impl EnabledHandler { &mut self, FullyNegotiatedOutbound { protocol, .. }: FullyNegotiatedOutbound< ::OutboundProtocol, - ::OutboundOpenInfo, >, ) { let (substream, peer_kind) = protocol; @@ -221,7 +220,7 @@ impl EnabledHandler { ) -> Poll< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, > { @@ -427,7 +426,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type OutboundProtocol = ProtocolConfig; - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { match self { Handler::Enabled(handler) => { SubstreamProtocol::new(either::Either::Left(handler.listen_protocol.clone()), ()) @@ -462,9 +461,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { match self { Handler::Enabled(handler) => handler.poll(cx), Handler::Disabled(DisabledHandler::ProtocolUnsupported { peer_kind_sent }) => { @@ -483,12 +480,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match self { Handler::Enabled(handler) => { diff --git a/protocols/identify/src/handler.rs b/protocols/identify/src/handler.rs index 6e5af290cd2..7acdfceb0a6 100644 --- a/protocols/identify/src/handler.rs +++ b/protocols/identify/src/handler.rs @@ -159,10 +159,7 @@ impl Handler { &mut self, FullyNegotiatedInbound { protocol: output, .. - }: FullyNegotiatedInbound< - ::InboundProtocol, - ::InboundOpenInfo, - >, + }: FullyNegotiatedInbound<::InboundProtocol>, ) { match output { future::Either::Left(stream) => { @@ -198,10 +195,7 @@ impl Handler { &mut self, FullyNegotiatedOutbound { protocol: output, .. - }: FullyNegotiatedOutbound< - ::OutboundProtocol, - ::OutboundOpenInfo, - >, + }: FullyNegotiatedOutbound<::OutboundProtocol>, ) { match output { future::Either::Left(stream) => { @@ -303,7 +297,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new( SelectUpgrade::new( ReadyUpgrade::new(PROTOCOL_NAME), @@ -334,7 +328,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { if let Some(event) = self.events.pop() { return Poll::Ready(event); } @@ -413,12 +407,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(fully_negotiated_inbound) => { diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 6837e3d499e..b848cf94410 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -476,10 +476,7 @@ impl Handler { FullyNegotiatedOutbound { protocol: stream, info: (), - }: FullyNegotiatedOutbound< - ::OutboundProtocol, - ::OutboundOpenInfo, - >, + }: FullyNegotiatedOutbound<::OutboundProtocol>, ) { if let Some(sender) = self.pending_streams.pop_front() { let _ = sender.send(Ok(stream)); @@ -500,7 +497,6 @@ impl Handler { &mut self, FullyNegotiatedInbound { protocol, .. }: FullyNegotiatedInbound< ::InboundProtocol, - ::InboundOpenInfo, >, ) { // If `self.allow_listening` is false, then we produced a `DeniedUpgrade` and `protocol` @@ -608,7 +604,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { match self.mode { Mode::Server => SubstreamProtocol::new(Either::Left(self.protocol_config.clone()), ()), Mode::Client => SubstreamProtocol::new(Either::Right(upgrade::DeniedUpgrade), ()), @@ -719,9 +715,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { loop { match &mut self.protocol_status { Some(status) if !status.reported => { @@ -788,12 +782,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedOutbound(fully_negotiated_outbound) => { diff --git a/protocols/perf/src/client/handler.rs b/protocols/perf/src/client/handler.rs index fc427d8134c..043790822b5 100644 --- a/protocols/perf/src/client/handler.rs +++ b/protocols/perf/src/client/handler.rs @@ -58,7 +58,7 @@ pub struct Handler { queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, >, @@ -92,7 +92,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()) } @@ -106,12 +106,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { // TODO: remove when Rust 1.82 is MSRV @@ -161,9 +156,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { if let Some(event) = self.queued_events.pop_front() { return Poll::Ready(event); } diff --git a/protocols/perf/src/server/handler.rs b/protocols/perf/src/server/handler.rs index a78485cd9b5..6ecb19dbc18 100644 --- a/protocols/perf/src/server/handler.rs +++ b/protocols/perf/src/server/handler.rs @@ -70,7 +70,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = Infallible; type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(ReadyUpgrade::new(crate::PROTOCOL_NAME), ()) } @@ -82,12 +82,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { @@ -129,9 +124,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { loop { match self.inbound.poll_unpin(cx) { Poll::Ready(Ok(Ok(stats))) => { diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index c7d65c64500..510ff0553de 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -179,7 +179,7 @@ impl Handler { fn on_dial_upgrade_error( &mut self, DialUpgradeError { error, .. }: DialUpgradeError< - ::OutboundOpenInfo, + (), ::OutboundProtocol, >, ) { @@ -229,7 +229,7 @@ impl ConnectionHandler for Handler { type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol, ()> { + fn listen_protocol(&self) -> SubstreamProtocol> { SubstreamProtocol::new(ReadyUpgrade::new(PROTOCOL_NAME), ()) } @@ -340,12 +340,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/protocols/relay/src/behaviour/handler.rs b/protocols/relay/src/behaviour/handler.rs index 0a4fe11c00a..d714bf04fc9 100644 --- a/protocols/relay/src/behaviour/handler.rs +++ b/protocols/relay/src/behaviour/handler.rs @@ -343,7 +343,7 @@ pub struct Handler { queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, >, @@ -447,7 +447,7 @@ impl Handler { fn on_dial_upgrade_error( &mut self, DialUpgradeError { error, .. }: DialUpgradeError< - ::OutboundOpenInfo, + (), ::OutboundProtocol, >, ) { @@ -494,7 +494,7 @@ impl ConnectionHandler for Handler { type OutboundProtocol = ReadyUpgrade; type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(ReadyUpgrade::new(HOP_PROTOCOL_NAME), ()) } @@ -598,9 +598,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { // Return queued events. if let Some(event) = self.queued_events.pop_front() { return Poll::Ready(event); @@ -876,12 +874,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/protocols/relay/src/priv_client/handler.rs b/protocols/relay/src/priv_client/handler.rs index 8f60b689ec8..d2e4db56b4c 100644 --- a/protocols/relay/src/priv_client/handler.rs +++ b/protocols/relay/src/priv_client/handler.rs @@ -107,7 +107,7 @@ pub struct Handler { queued_events: VecDeque< ConnectionHandlerEvent< ::OutboundProtocol, - ::OutboundOpenInfo, + (), ::ToBehaviour, >, >, @@ -241,7 +241,7 @@ impl ConnectionHandler for Handler { type OutboundProtocol = ReadyUpgrade; type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(ReadyUpgrade::new(STOP_PROTOCOL_NAME), ()) } @@ -267,9 +267,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { loop { // Reservations match self.inflight_reserve_requests.poll_unpin(cx) { @@ -426,12 +424,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index 133cff87f40..d70ddc5c0ae 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -127,10 +127,7 @@ where FullyNegotiatedInbound { protocol: (mut stream, protocol), info: (), - }: FullyNegotiatedInbound< - ::InboundProtocol, - ::InboundOpenInfo, - >, + }: FullyNegotiatedInbound<::InboundProtocol>, ) { let mut codec = self.codec.clone(); let request_id = self.next_inbound_request_id(); @@ -178,10 +175,7 @@ where FullyNegotiatedOutbound { protocol: (mut stream, protocol), info: (), - }: FullyNegotiatedOutbound< - ::OutboundProtocol, - ::OutboundOpenInfo, - >, + }: FullyNegotiatedOutbound<::OutboundProtocol>, ) { let message = self .requested_outbound @@ -219,7 +213,7 @@ where fn on_dial_upgrade_error( &mut self, DialUpgradeError { error, info: () }: DialUpgradeError< - ::OutboundOpenInfo, + (), ::OutboundProtocol, >, ) { @@ -256,7 +250,7 @@ where fn on_listen_upgrade_error( &mut self, ListenUpgradeError { error, .. }: ListenUpgradeError< - ::InboundOpenInfo, + (), ::InboundProtocol, >, ) { @@ -383,7 +377,7 @@ where type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new( Protocol { protocols: self.inbound_protocols.clone(), @@ -473,12 +467,7 @@ where fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(fully_negotiated_inbound) => { diff --git a/protocols/stream/src/handler.rs b/protocols/stream/src/handler.rs index d626f48fb09..5fc903f5980 100644 --- a/protocols/stream/src/handler.rs +++ b/protocols/stream/src/handler.rs @@ -52,9 +52,7 @@ impl ConnectionHandler for Handler { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol( - &self, - ) -> swarm::SubstreamProtocol { + fn listen_protocol(&self) -> swarm::SubstreamProtocol { swarm::SubstreamProtocol::new( Upgrade { supported_protocols: Shared::lock(&self.shared).supported_inbound_protocols(), @@ -66,13 +64,7 @@ impl ConnectionHandler for Handler { fn poll( &mut self, cx: &mut Context<'_>, - ) -> Poll< - swarm::ConnectionHandlerEvent< - Self::OutboundProtocol, - Self::OutboundOpenInfo, - Self::ToBehaviour, - >, - > { + ) -> Poll> { if self.pending_upgrade.is_some() { return Poll::Pending; } @@ -104,12 +96,7 @@ impl ConnectionHandler for Handler { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/swarm/benches/connection_handler.rs b/swarm/benches/connection_handler.rs index a5e47528308..3ae75288208 100644 --- a/swarm/benches/connection_handler.rs +++ b/swarm/benches/connection_handler.rs @@ -281,9 +281,7 @@ impl ConnectionHandler for SpinningHandler { type OutboundOpenInfo = (); - fn listen_protocol( - &self, - ) -> libp2p_swarm::SubstreamProtocol { + fn listen_protocol(&self) -> libp2p_swarm::SubstreamProtocol { libp2p_swarm::SubstreamProtocol::new(Upgrade(self.protocols), ()) } @@ -291,11 +289,7 @@ impl ConnectionHandler for SpinningHandler { &mut self, cx: &mut std::task::Context<'_>, ) -> std::task::Poll< - libp2p_swarm::ConnectionHandlerEvent< - Self::OutboundProtocol, - Self::OutboundOpenInfo, - Self::ToBehaviour, - >, + libp2p_swarm::ConnectionHandlerEvent, > { if self.iter_count == usize::MAX { return std::task::Poll::Pending; @@ -322,8 +316,6 @@ impl ConnectionHandler for SpinningHandler { _event: libp2p_swarm::handler::ConnectionEvent< Self::InboundProtocol, Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, >, ) { } diff --git a/swarm/src/behaviour/toggle.rs b/swarm/src/behaviour/toggle.rs index e70e6cf9896..a706187a40c 100644 --- a/swarm/src/behaviour/toggle.rs +++ b/swarm/src/behaviour/toggle.rs @@ -200,6 +200,7 @@ impl ToggleConnectionHandler where TInner: ConnectionHandler, { + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. fn on_fully_negotiated_inbound( &mut self, FullyNegotiatedInbound { @@ -231,7 +232,7 @@ where panic!("Unexpected Either::Right in enabled `on_fully_negotiated_inbound`.") } } - + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. fn on_listen_upgrade_error( &mut self, ListenUpgradeError { info, error: err }: ListenUpgradeError< @@ -267,6 +268,7 @@ where } } +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl ConnectionHandler for ToggleConnectionHandler where TInner: ConnectionHandler, diff --git a/swarm/src/connection.rs b/swarm/src/connection.rs index a1c7b2a2f20..8e913aa80e5 100644 --- a/swarm/src/connection.rs +++ b/swarm/src/connection.rs @@ -123,6 +123,7 @@ where /// The underlying handler. handler: THandler, /// Futures that upgrade incoming substreams. + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. negotiating_in: FuturesUnordered< StreamUpgrade< THandler::InboundOpenInfo, @@ -131,6 +132,7 @@ where >, >, /// Futures that upgrade outgoing substreams. + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. negotiating_out: FuturesUnordered< StreamUpgrade< THandler::OutboundOpenInfo, @@ -155,6 +157,7 @@ where /// /// The upgrade timeout is already ticking here so this may fail in case the remote is not /// quick enough in providing us with a new stream. + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. requested_substreams: FuturesUnordered< SubstreamRequested, >, @@ -168,6 +171,7 @@ where stream_counter: ActiveStreamCounter, } +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl fmt::Debug for Connection where THandler: ConnectionHandler + fmt::Debug, @@ -1189,20 +1193,13 @@ mod tests { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol( - &self, - ) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()).with_timeout(self.upgrade_timeout) } fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { // TODO: remove when Rust 1.82 is MSRV @@ -1242,13 +1239,7 @@ mod tests { fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent< - Self::OutboundProtocol, - Self::OutboundOpenInfo, - Self::ToBehaviour, - >, - > { + ) -> Poll> { if self.outbound_requested { self.outbound_requested = false; return Poll::Ready(ConnectionHandlerEvent::OutboundSubstreamRequest { @@ -1269,9 +1260,7 @@ mod tests { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol( - &self, - ) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new( ManyProtocolsUpgrade { protocols: Vec::from_iter(self.active_protocols.clone()), @@ -1282,12 +1271,7 @@ mod tests { fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::LocalProtocolsChange(ProtocolsChange::Added(added)) => { @@ -1319,13 +1303,7 @@ mod tests { fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent< - Self::OutboundProtocol, - Self::OutboundOpenInfo, - Self::ToBehaviour, - >, - > { + ) -> Poll> { if let Some(event) = self.events.pop() { return Poll::Ready(event); } diff --git a/swarm/src/connection/pool.rs b/swarm/src/connection/pool.rs index 49cc774b2b7..f21a7307105 100644 --- a/swarm/src/connection/pool.rs +++ b/swarm/src/connection/pool.rs @@ -553,6 +553,7 @@ where /// Polls the connection pool for events. #[tracing::instrument(level = "debug", name = "Pool::poll", skip(self, cx))] + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. pub(crate) fn poll(&mut self, cx: &mut Context<'_>) -> Poll> where THandler: ConnectionHandler + 'static, diff --git a/swarm/src/dummy.rs b/swarm/src/dummy.rs index 5452c382cd4..f8137bdbeee 100644 --- a/swarm/src/dummy.rs +++ b/swarm/src/dummy.rs @@ -71,9 +71,9 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { type InboundProtocol = DeniedUpgrade; type OutboundProtocol = DeniedUpgrade; type InboundOpenInfo = (); - type OutboundOpenInfo = Infallible; + type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()) } @@ -86,20 +86,13 @@ impl crate::handler::ConnectionHandler for ConnectionHandler { fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { Poll::Pending } fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { // TODO: remove when Rust 1.82 is MSRV diff --git a/swarm/src/handler.rs b/swarm/src/handler.rs index 3d0407b4f70..d9293fa41de 100644 --- a/swarm/src/handler.rs +++ b/swarm/src/handler.rs @@ -98,6 +98,7 @@ use crate::{connection::AsStrHashEq, StreamProtocol}; /// Implementors of this trait should keep in mind that the connection can be closed at any time. /// When a connection is closed gracefully, the substreams used by the handler may still /// continue reading data until the remote closes its side of the connection. +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. pub trait ConnectionHandler: Send + 'static { /// A type representing the message(s) a /// [`NetworkBehaviour`](crate::behaviour::NetworkBehaviour) can send to a [`ConnectionHandler`] @@ -112,8 +113,10 @@ pub trait ConnectionHandler: Send + 'static { /// The outbound upgrade for the protocol(s) used by the handler. type OutboundProtocol: OutboundUpgradeSend; /// The type of additional information returned from `listen_protocol`. + #[deprecated = "Track data in ConnectionHandler instead."] type InboundOpenInfo: Send + 'static; /// The type of additional information passed to an `OutboundSubstreamRequest`. + #[deprecated = "Track data in ConnectionHandler instead."] type OutboundOpenInfo: Send + 'static; /// The [`InboundUpgrade`](libp2p_core::upgrade::InboundUpgrade) to apply on inbound @@ -224,7 +227,7 @@ pub trait ConnectionHandler: Send + 'static { /// Enumeration with the list of the possible stream events /// to pass to [`on_connection_event`](ConnectionHandler::on_connection_event). #[non_exhaustive] -pub enum ConnectionEvent<'a, IP: InboundUpgradeSend, OP: OutboundUpgradeSend, IOI, OOI> { +pub enum ConnectionEvent<'a, IP: InboundUpgradeSend, OP: OutboundUpgradeSend, IOI = (), OOI = ()> { /// Informs the handler about the output of a successful upgrade on a new inbound substream. FullyNegotiatedInbound(FullyNegotiatedInbound), /// Informs the handler about the output of a successful upgrade on a new outbound stream. @@ -318,7 +321,7 @@ impl /// [`ConnectionHandler`] implementation to stop a malicious remote node to open and keep alive /// an excessive amount of inbound substreams. #[derive(Debug)] -pub struct FullyNegotiatedInbound { +pub struct FullyNegotiatedInbound { pub protocol: IP::Output, pub info: IOI, } @@ -329,7 +332,7 @@ pub struct FullyNegotiatedInbound { /// The `protocol` field is the information that was previously passed to /// [`ConnectionHandlerEvent::OutboundSubstreamRequest`]. #[derive(Debug)] -pub struct FullyNegotiatedOutbound { +pub struct FullyNegotiatedOutbound { pub protocol: OP::Output, pub info: OOI, } @@ -524,7 +527,7 @@ pub struct ListenUpgradeError { /// The inbound substream protocol(s) are defined by [`ConnectionHandler::listen_protocol`] /// and the outbound substream protocol(s) by [`ConnectionHandlerEvent::OutboundSubstreamRequest`]. #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub struct SubstreamProtocol { +pub struct SubstreamProtocol { upgrade: TUpgrade, info: TInfo, timeout: Duration, diff --git a/swarm/src/handler/either.rs b/swarm/src/handler/either.rs index 1dc62e0eb2a..a349726f454 100644 --- a/swarm/src/handler/either.rs +++ b/swarm/src/handler/either.rs @@ -77,6 +77,7 @@ where /// Implementation of a [`ConnectionHandler`] that represents either of two [`ConnectionHandler`] /// implementations. +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl ConnectionHandler for Either where L: ConnectionHandler, diff --git a/swarm/src/handler/map_in.rs b/swarm/src/handler/map_in.rs index 55885b351bb..7a5166cab75 100644 --- a/swarm/src/handler/map_in.rs +++ b/swarm/src/handler/map_in.rs @@ -47,6 +47,7 @@ impl MapInEvent ConnectionHandler for MapInEvent where diff --git a/swarm/src/handler/map_out.rs b/swarm/src/handler/map_out.rs index 6d05551aeec..9bb0e2bc554 100644 --- a/swarm/src/handler/map_out.rs +++ b/swarm/src/handler/map_out.rs @@ -43,6 +43,7 @@ impl MapOutEvent { } } +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl ConnectionHandler for MapOutEvent where TConnectionHandler: ConnectionHandler, diff --git a/swarm/src/handler/multi.rs b/swarm/src/handler/multi.rs index 73af1b1109e..4f4d64f65fe 100644 --- a/swarm/src/handler/multi.rs +++ b/swarm/src/handler/multi.rs @@ -86,6 +86,7 @@ where Ok(m) } + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. fn on_listen_upgrade_error( &mut self, ListenUpgradeError { @@ -107,6 +108,7 @@ where } } +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl ConnectionHandler for MultiHandler where K: Clone + Debug + Hash + Eq + Send + 'static, diff --git a/swarm/src/handler/one_shot.rs b/swarm/src/handler/one_shot.rs index 29f2811522b..c623008dd90 100644 --- a/swarm/src/handler/one_shot.rs +++ b/swarm/src/handler/one_shot.rs @@ -129,7 +129,7 @@ where type OutboundOpenInfo = (); type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { self.listen_protocol.clone() } @@ -140,9 +140,7 @@ where fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { if !self.events_out.is_empty() { return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( self.events_out.remove(0), @@ -169,12 +167,7 @@ where fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { ConnectionEvent::FullyNegotiatedInbound(FullyNegotiatedInbound { diff --git a/swarm/src/handler/pending.rs b/swarm/src/handler/pending.rs index 483c4b3d6e8..8223c544593 100644 --- a/swarm/src/handler/pending.rs +++ b/swarm/src/handler/pending.rs @@ -51,7 +51,7 @@ impl ConnectionHandler for PendingConnectionHandler { type OutboundOpenInfo = Infallible; type InboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(PendingUpgrade::new(self.protocol_name.clone()), ()) } @@ -64,20 +64,13 @@ impl ConnectionHandler for PendingConnectionHandler { fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { Poll::Pending } fn on_connection_event( &mut self, - event: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + event: ConnectionEvent, ) { match event { // TODO: remove when Rust 1.82 is MSRV diff --git a/swarm/src/handler/select.rs b/swarm/src/handler/select.rs index 0f6dbe988ff..f4c926f1a0e 100644 --- a/swarm/src/handler/select.rs +++ b/swarm/src/handler/select.rs @@ -152,6 +152,7 @@ where TProto1: ConnectionHandler, TProto2: ConnectionHandler, { + #[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. fn on_listen_upgrade_error( &mut self, ListenUpgradeError { @@ -181,6 +182,7 @@ where } } +#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed. impl ConnectionHandler for ConnectionHandlerSelect where TProto1: ConnectionHandler, diff --git a/swarm/tests/connection_close.rs b/swarm/tests/connection_close.rs index bc71216870a..0d95626b2f0 100644 --- a/swarm/tests/connection_close.rs +++ b/swarm/tests/connection_close.rs @@ -103,7 +103,7 @@ impl ConnectionHandler for HandlerWithState { type InboundOpenInfo = (); type OutboundOpenInfo = (); - fn listen_protocol(&self) -> SubstreamProtocol { + fn listen_protocol(&self) -> SubstreamProtocol { SubstreamProtocol::new(DeniedUpgrade, ()) } @@ -114,9 +114,7 @@ impl ConnectionHandler for HandlerWithState { fn poll( &mut self, _: &mut Context<'_>, - ) -> Poll< - ConnectionHandlerEvent, - > { + ) -> Poll> { Poll::Pending } @@ -137,12 +135,7 @@ impl ConnectionHandler for HandlerWithState { fn on_connection_event( &mut self, - _: ConnectionEvent< - Self::InboundProtocol, - Self::OutboundProtocol, - Self::InboundOpenInfo, - Self::OutboundOpenInfo, - >, + _: ConnectionEvent, ) { } }