sfackler / rust-native-tls

Apache License 2.0
473 stars 197 forks source link

Is `&TlsStream: Read + Write` possible? #276

Closed rMazeiks closed 1 year ago

rMazeiks commented 1 year ago

TlsStream implements Read and Write. However, &TlsStream doesn't, unlike &std::net::TcpStream.

Is it possible to implement these traits for references to TlsStream as well?

Use case: I need to share a TlsStream accross 2 threads. I want to read from it in one thread, and write to it in another. Unfortunately, this means that I have to use a Mutex to synchronize access, which leads to deadlock if the reading thread is blocking, waiting for data that won't come until the writing thread sends something.

Related SO post

Thank you!

sfackler commented 1 year ago

It is not.

rMazeiks commented 1 year ago

Bit curious why, but I'll take your word for it :laughing:

Thanks for the quick reply!