Created
June 18, 2025 19:34
-
-
Save mcr/0f0a7ac92a48ea49475f4b8d052dcf86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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