actix / actix-net

A collection of lower-level libraries for composable network services.
https://actix.rs
Apache License 2.0
703 stars 345 forks source link

actix-codec: Support Half streams #453

Open aviramha opened 2 years ago

aviramha commented 2 years ago

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.

asonix commented 2 years ago

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

aviramha commented 2 years ago

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)