Tokio-util Framed and flushing

⚓ Rust    📅 2025-06-23    👤 surdeus    👁️ 6      

surdeus

Warning

This post was published 50 days ago. The information described in this article may have changed.

tokio-rustls is very clear about the need to explicitly flush. I put a tokio-rustls stream in a tokio-util Framed and didn't explicitly flush, and it seemed to work fine, to the point where I started assuming that Framed must be explicitly flushing each frame sent to it via its Encoder. However, recently I've been having some hiccups that look suspiciously like an effect of absent explicit flushes, so I thought I'd assume I was wrong and add them to see if the problem goes away.

Naively I thought I could just call frmio.flush().await, but it [the compiler] tells me I need some type annotations, and suggests this beauty:

<Framed<C, Codec> as futures::SinkExt<&MyType>>::flush(frmio).await;

(C is a generic with a AsyncWrite + Unpin + Send bound).

It feels a little strange to have to tell it what type (MyType) is being flushed. Just want to make sure -- what is the proper way to flush a Framed/FramedWrite?

1 post - 1 participant

Read full topic

🏷️ rust_feed