Using Encoder from tokio-util's Framed Decoder

Is it possible to send data from a Framed Decoder?

We have a protocol that receives a header followed by zero or more components, each of which is ACK'd. We're currently receiving one component at a time [i.e. return it to the application], and the application ACK's each and prepares to receive the next component. This feel more or less exactly as Framed was intended to be used.

There are a few very common cases that we'd like to wrap in the Decoder. I.e. we'd like to receive all three components and return, to the application, a structure containing all the components in one go. However, we still need to ACK each component, and that would need to be done from inside the Decoder (if we want to hide all of the logic from the application).

I guess we could always create a dummy return value that is returned from the decoder that just tells the application that it's time to send an ACK.. But preferably I'd want to keep everything hidden from the application.

Is this possible?

I would probably return the dummy return value that says it's time to send an ACK. If you wish to hide it, you can wrap the codec in another layer whose responsibility is to handle the acks.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.