quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.85k stars 394 forks source link

Receive `Finished` flag along with data #1567

Closed serzhiio closed 1 year ago

serzhiio commented 1 year ago

As i see currently you need to call .finish() after all data is sent, and you need to wait for Finished event to be sure data stream is fully drained. It would be more convenient, in my particular case, to receive this flag along with last portion of data, almost like WebSockets FIN flag. The Api could look like:

match recv_stream.read(false) {
  Ok(mut chunks) => {
      loop {
          match chunks.next(u16::MAX as _) {
               Ok(Some(chunk)) => {
                    callback(chunk.bytes.as_ref(), chunk.is_fin())
               }
               ...
          }
      }
}
Ralith commented 1 year ago

Chunks::next returns Ok(None) when you've reached the end of the stream.

serzhiio commented 1 year ago

Yeah, but if i wait for this extra event i need to cache all stream data even if there is only one chunk. And when receiving data with fin:true flag i can parse it without caching bc i know i don't have to wait.

Ralith commented 1 year ago

Your code needs to handle data being delivered in arbitrary chunks regardless.