Skip to content

Commit

Permalink
implement Debug/Clone conditionally for new stream select types
Browse files Browse the repository at this point in the history
GlenDC committed Nov 19, 2024
1 parent 7ff258c commit b4b4b17
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions rama-tcp/src/client/service/select.rs
Original file line number Diff line number Diff line change
@@ -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<State, Connector> {
pub connector: Connector,
}

impl<State, Connector> fmt::Debug for CreatedTcpStreamConnector<State, Connector>
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<State, Connector> Clone for CreatedTcpStreamConnector<State, Connector>
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<State: Send + Sync + 'static> TcpStreamConnectorFactory<State> for () {
/// and instead is to be used via other API's provided by this crate.
pub struct TcpStreamConnectorCloneFactory<C>(pub(super) C);

impl<C> fmt::Debug for TcpStreamConnectorCloneFactory<C>
where
C: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("TcpStreamConnectorCloneFactory")
.field(&self.0)
.finish()
}
}

impl<C> Clone for TcpStreamConnectorCloneFactory<C>
where
C: Clone,
{
fn clone(&self) -> Self {
Self(self.0.clone())
}
}

impl<State, C> TcpStreamConnectorFactory<State> for TcpStreamConnectorCloneFactory<C>
where
C: TcpStreamConnector + Clone,

0 comments on commit b4b4b17

Please sign in to comment.