From 3d74bfe05e72b5db540aef324d6456f3e836c729 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Wed, 13 Nov 2024 18:29:48 +0100 Subject: [PATCH] remove Arc from WebSocket Connection --- crates/servicepoint/src/connection.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/servicepoint/src/connection.rs b/crates/servicepoint/src/connection.rs index 3626bc8..9d53611 100644 --- a/crates/servicepoint/src/connection.rs +++ b/crates/servicepoint/src/connection.rs @@ -34,11 +34,9 @@ pub enum Connection { /// [servicepoint-websocket-relay]: https://github.com/kaesaecracker/servicepoint-websocket-relay #[cfg(feature = "protocol_websocket")] WebSocket( - std::sync::Arc< - std::sync::Mutex< - tungstenite::WebSocket< - tungstenite::stream::MaybeTlsStream, - >, + std::sync::Mutex< + tungstenite::WebSocket< + tungstenite::stream::MaybeTlsStream, >, >, ), @@ -109,9 +107,9 @@ impl Connection { let request = ClientRequestBuilder::new(uri).into_client_request()?; let (sock, _) = connect(request)?; - Ok(Self::WebSocket(std::sync::Arc::new(std::sync::Mutex::new( + Ok(Self::WebSocket(std::sync::Mutex::new( sock, - )))) + ))) } /// Send something packet-like to the display. Usually this is in the form of a Command. @@ -163,7 +161,7 @@ impl Drop for Connection { if let Connection::WebSocket(sock) = self { _ = sock .try_lock() - .map(move |mut sock| sock.close(None).unwrap()); + .map(move |mut sock| sock.close(None)); } } }