actix-net icon indicating copy to clipboard operation
actix-net copied to clipboard

actix-codec: Support Half streams

Open aviramha opened this issue 2 years ago • 2 comments

Right now the codec supports only IO that has both AsyncRead and AsyncWrite. I have a situation where the incoming codec != outgoing codec (different messages and I'd like to distinguish). Ideally, I could use TcpStream::split() then create each half with a codec, but I can't do that because of both traits required. I'm thinking we should add ReadFramed and WriteFramed to support that.

aviramha avatar Apr 04 '22 17:04 aviramha

I'm also wondering if there is a specific reason that actix-codec is distinct from tokio-util::codec

asonix avatar Apr 04 '22 18:04 asonix

I'm also wondering if there is a specific reason that actix-codec is distinct from tokio-util::codec

Ah! I didn't even notice it. TBH I solved it by creating 2 codecs, one for the "client" and other for the "server" which each one encodes/decodes different data.. not sure how elegant it is (prior solution was a generic codec)

aviramha avatar Apr 04 '22 18:04 aviramha