diff --git a/ewebsock/src/native_tungstenite.rs b/ewebsock/src/native_tungstenite.rs index ce81981..c5d1e84 100644 --- a/ewebsock/src/native_tungstenite.rs +++ b/ewebsock/src/native_tungstenite.rs @@ -16,9 +16,7 @@ pub struct WsSender { impl Drop for WsSender { fn drop(&mut self) { - if let Err(err) = self.close() { - log::warn!("Failed to close web-socket: {err:?}"); - } + self.close(); } } @@ -35,16 +33,11 @@ impl WsSender { /// Close the connection. /// /// This is called automatically when the sender is dropped. - /// - /// # Errors - /// This should never fail, except _maybe_ on Web. - #[allow(clippy::unnecessary_wraps)] // To keep the same signature as the Web version - pub fn close(&mut self) -> Result<()> { + pub fn close(&mut self) { if self.tx.is_some() { log::debug!("Closing WebSocket"); } self.tx = None; - Ok(()) } /// Forget about this sender without closing the connection. diff --git a/ewebsock/src/native_tungstenite_tokio.rs b/ewebsock/src/native_tungstenite_tokio.rs index 8af346d..0676c39 100644 --- a/ewebsock/src/native_tungstenite_tokio.rs +++ b/ewebsock/src/native_tungstenite_tokio.rs @@ -11,9 +11,7 @@ pub struct WsSender { impl Drop for WsSender { fn drop(&mut self) { - if let Err(err) = self.close() { - log::warn!("Failed to close web-socket: {err:?}"); - } + self.close(); } } @@ -30,16 +28,11 @@ impl WsSender { /// Close the connection. /// /// This is called automatically when the sender is dropped. - /// - /// # Errors - /// This should never fail, except _maybe_ on Web. - #[allow(clippy::unnecessary_wraps)] // To keep the same signature as the Web version - pub fn close(&mut self) -> Result<()> { + pub fn close(&mut self) { if self.tx.is_some() { log::debug!("Closing WebSocket"); } self.tx = None; - Ok(()) } /// Forget about this sender without closing the connection. diff --git a/ewebsock/src/web.rs b/ewebsock/src/web.rs index 8ea356a..f6080b3 100644 --- a/ewebsock/src/web.rs +++ b/ewebsock/src/web.rs @@ -23,9 +23,7 @@ pub struct WsSender { impl Drop for WsSender { fn drop(&mut self) { - if let Err(err) = self.close() { - log::warn!("Failed to close WebSocket: {err:?}"); - } + self.close(); } } @@ -52,14 +50,10 @@ impl WsSender { /// Close the connection. /// /// This is called automatically when the sender is dropped. - /// - /// # Errors - /// This should never fail, except _maybe_ on Web. - pub fn close(&mut self) -> Result<()> { + pub fn close(&mut self) { if let Some(socket) = self.socket.take() { close_socket(&socket); } - Ok(()) } /// Forget about this sender without closing the connection.