From b4b4b171feae7370d014a72746f86ef75fb23ae2 Mon Sep 17 00:00:00 2001 From: glendc Date: Tue, 19 Nov 2024 09:22:24 +0100 Subject: [PATCH] implement Debug/Clone conditionally for new stream select types --- rama-tcp/src/client/service/select.rs | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/rama-tcp/src/client/service/select.rs b/rama-tcp/src/client/service/select.rs index 997b61c58..5a0552366 100644 --- a/rama-tcp/src/client/service/select.rs +++ b/rama-tcp/src/client/service/select.rs @@ -1,5 +1,6 @@ use rama_core::error::BoxError; use rama_core::Context; +use std::fmt; use std::{convert::Infallible, future::Future, sync::Arc}; use crate::client::TcpStreamConnector; @@ -11,6 +12,32 @@ pub struct CreatedTcpStreamConnector { pub connector: Connector, } +impl fmt::Debug for CreatedTcpStreamConnector +where + State: fmt::Debug, + Connector: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CreatedTcpStreamConnector") + .field("ctx", &self.ctx) + .field("connector", &self.connector) + .finish() + } +} + +impl Clone for CreatedTcpStreamConnector +where + State: Clone, + Connector: Clone, +{ + fn clone(&self) -> Self { + Self { + ctx: self.ctx.clone(), + connector: self.connector.clone(), + } + } +} + /// Factory to create a [`TcpStreamConnector`]. This is used by the TCP /// stream service to create a stream within a specific [`Context`]. /// @@ -66,6 +93,26 @@ impl TcpStreamConnectorFactory for () { /// and instead is to be used via other API's provided by this crate. pub struct TcpStreamConnectorCloneFactory(pub(super) C); +impl fmt::Debug for TcpStreamConnectorCloneFactory +where + C: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("TcpStreamConnectorCloneFactory") + .field(&self.0) + .finish() + } +} + +impl Clone for TcpStreamConnectorCloneFactory +where + C: Clone, +{ + fn clone(&self) -> Self { + Self(self.0.clone()) + } +} + impl TcpStreamConnectorFactory for TcpStreamConnectorCloneFactory where C: TcpStreamConnector + Clone,