Skip to content

Instantly share code, notes, and snippets.

@mcr
Created June 18, 2025 19:34
Show Gist options
  • Save mcr/0f0a7ac92a48ea49475f4b8d052dcf86 to your computer and use it in GitHub Desktop.
Save mcr/0f0a7ac92a48ea49475f4b8d052dcf86 to your computer and use it in GitHub Desktop.
// implement a Connector that does nothing
#[derive(Debug)]
pub struct NoConnector {
pub stream: TcpStream
}
impl NoConnector {
pub fn new(stream: TcpStream) -> Self {
NoConnector { stream }
}
}
impl<In: Transport> Connector<In> for NoConnector {
type Out = Either<In, TcpTransport>;
fn connect(
&self,
details: &ConnectionDetails,
_chained: Option<In>,
) -> Result<Option<Self::Out>, Error> {
let config = &details.config;
let buffers = LazyBuffers::new(config.input_buffer_size(), config.output_buffer_size());
let transport = TcpTransport::new(self.stream.try_clone().unwrap(), buffers);
//debug!("connected");
Ok(Some(Either::B(transport)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment