From 885af263ffc4b31fb27e37c9a67d74f983df79c1 Mon Sep 17 00:00:00 2001 From: neonphog Date: Fri, 11 Oct 2024 13:57:03 -0600 Subject: [PATCH] address code review comment --- crates/tx5/src/backend.rs | 12 ++++++------ crates/tx5/src/backend/go_pion.rs | 17 +++++++++-------- crates/tx5/src/sig.rs | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/tx5/src/backend.rs b/crates/tx5/src/backend.rs index 6149e1f..b7e2506 100644 --- a/crates/tx5/src/backend.rs +++ b/crates/tx5/src/backend.rs @@ -55,7 +55,7 @@ impl BackendModule { url: &str, listener: bool, config: &Arc, - ) -> Result<(DynBackEp, DynBackEpRecv)> { + ) -> Result<(DynBackEp, DynBackEpRecvCon)> { match self { #[cfg(feature = "backend-go-pion")] Self::GoPion => go_pion::connect(config, url, listener).await, @@ -87,13 +87,13 @@ pub trait BackCon: 'static + Send + Sync { pub type DynBackCon = Arc; /// Backend connection receiver. -pub trait BackConRecv: 'static + Send { +pub trait BackConRecvData: 'static + Send { /// Receive data from this backend connection. fn recv(&mut self) -> BoxFuture<'_, Option>>; } /// Trait-object version of backend connection receiver. -pub type DynBackConRecv = Box; +pub type DynBackConRecvData = Box; /// Pending connection. pub trait BackWaitCon: 'static + Send { @@ -102,7 +102,7 @@ pub trait BackWaitCon: 'static + Send { &mut self, // TODO - this isn't good encapsulation recv_limit: Arc, - ) -> BoxFuture<'static, Result<(DynBackCon, DynBackConRecv)>>; + ) -> BoxFuture<'static, Result<(DynBackCon, DynBackConRecvData)>>; /// Get the pub_key identifying this connection. fn pub_key(&self) -> &PubKey; @@ -125,10 +125,10 @@ pub trait BackEp: 'static + Send + Sync { pub type DynBackEp = Arc; /// Backend endpoint receiver. -pub trait BackEpRecv: 'static + Send { +pub trait BackEpRecvCon: 'static + Send { /// Receive incoming connection from this backend endpoint. fn recv(&mut self) -> BoxFuture<'_, Option>; } /// Trait-object version of backend endpoint receiver. -pub type DynBackEpRecv = Box; +pub type DynBackEpRecvCon = Box; diff --git a/crates/tx5/src/backend/go_pion.rs b/crates/tx5/src/backend/go_pion.rs index 2271398..a7e8eea 100644 --- a/crates/tx5/src/backend/go_pion.rs +++ b/crates/tx5/src/backend/go_pion.rs @@ -23,9 +23,9 @@ impl BackCon for GoCon { } } -struct GoConRecv(tx5_connection::FramedConnRecv); +struct GoConRecvData(tx5_connection::FramedConnRecv); -impl BackConRecv for GoConRecv { +impl BackConRecvData for GoConRecvData { fn recv(&mut self) -> BoxFuture<'_, Option>> { Box::pin(async { self.0.recv().await }) } @@ -41,7 +41,7 @@ impl BackWaitCon for GoWaitCon { fn wait( &mut self, recv_limit: Arc, - ) -> BoxFuture<'static, Result<(DynBackCon, DynBackConRecv)>> { + ) -> BoxFuture<'static, Result<(DynBackCon, DynBackConRecvData)>> { let con = self.con.take(); let con_recv = self.con_recv.take(); Box::pin(async move { @@ -57,7 +57,8 @@ impl BackWaitCon for GoWaitCon { .await?; let con: DynBackCon = Arc::new(GoCon(con)); - let con_recv: DynBackConRecv = Box::new(GoConRecv(con_recv)); + let con_recv: DynBackConRecvData = + Box::new(GoConRecvData(con_recv)); Ok((con, con_recv)) }) @@ -92,9 +93,9 @@ impl BackEp for GoEp { } } -struct GoEpRecv(tx5_connection::HubRecv); +struct GoEpRecvCon(tx5_connection::HubRecv); -impl BackEpRecv for GoEpRecv { +impl BackEpRecvCon for GoEpRecvCon { fn recv(&mut self) -> BoxFuture<'_, Option> { Box::pin(async { let (con, con_recv) = self.0.accept().await?; @@ -119,7 +120,7 @@ pub async fn connect( config: &Arc, url: &str, listener: bool, -) -> Result<(DynBackEp, DynBackEpRecv)> { +) -> Result<(DynBackEp, DynBackEpRecvCon)> { let webrtc_config = config.initial_webrtc_config.clone().into_bytes(); let sig_config = tx5_connection::tx5_signal::SignalConfig { listener, @@ -132,6 +133,6 @@ pub async fn connect( tx5_connection::Hub::new(webrtc_config, url, Arc::new(sig_config)) .await?; let ep: DynBackEp = Arc::new(GoEp(hub)); - let ep_recv: DynBackEpRecv = Box::new(GoEpRecv(hub_recv)); + let ep_recv: DynBackEpRecvCon = Box::new(GoEpRecvCon(hub_recv)); Ok((ep, ep_recv)) } diff --git a/crates/tx5/src/sig.rs b/crates/tx5/src/sig.rs index 0fde733..81ac269 100644 --- a/crates/tx5/src/sig.rs +++ b/crates/tx5/src/sig.rs @@ -83,7 +83,7 @@ async fn connect_loop( sig_url: SigUrl, listener: bool, mut resp_url: Option>, -) -> (DynBackEp, DynBackEpRecv) { +) -> (DynBackEp, DynBackEpRecvCon) { tracing::debug!( target: "NETAUDIT", ?config,