From 9eb947fe3b600af4e0a8744768e0ba9c94122b49 Mon Sep 17 00:00:00 2001 From: Chris Connelly Date: Fri, 20 Aug 2021 11:23:20 +0100 Subject: [PATCH] refactor!: Make `Endpoint::disconnect_from` infallible This function can never return an error. BREAKING CHANGE: `Endpoint::disconnect_from` now returns `()`. --- src/endpoint.rs | 3 +-- src/tests/common.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/endpoint.rs b/src/endpoint.rs index a78a26e6..8484aa43 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -322,7 +322,7 @@ impl Endpoint { } /// Removes all existing connections to a given peer - pub async fn disconnect_from(&self, peer_addr: &SocketAddr) -> Result<()> { + pub async fn disconnect_from(&self, peer_addr: &SocketAddr) { self.connection_pool .remove(peer_addr) .await @@ -330,7 +330,6 @@ impl Endpoint { .for_each(|conn| { conn.close(0u8.into(), b""); }); - Ok(()) } /// Connects to another peer, retries for `config.retry_duration_msec` if the connection fails. diff --git a/src/tests/common.rs b/src/tests/common.rs index f1562f66..c138d2cc 100644 --- a/src/tests/common.rs +++ b/src/tests/common.rs @@ -191,7 +191,7 @@ async fn disconnection() -> Result<()> { } // After Alice disconnects from Bob both peers should receive the disconnected event. - alice.disconnect_from(&bob_addr).await?; + alice.disconnect_from(&bob_addr).await; if let Some(disconnected_peer) = alice_disconnections.next().await { assert_eq!(disconnected_peer, bob_addr); @@ -271,7 +271,7 @@ async fn simultaneous_incoming_and_outgoing_connections() -> Result<()> { } // Drop the connection initiated by Bob. - bob.disconnect_from(&alice_addr).await?; + bob.disconnect_from(&alice_addr).await; // It should be closed on Alice's side too. if let Some(disconnected_peer) = alice_disconnections.next().await {