There's currently no way in quinn_proto::SendStream (and consequently quinn::SendStream) to perform all-or-nothing writes.
As a concrete example, I have a &mut [Bytes] that I'd like to write to a quinn::SendStream in its entirety if there's sufficient send capacity, or not at all. The end-user API could look something like fn try_write_all_chunks(&mut self, bufs: &mut [Bytes]) -> Result<(), WriteError> - note that this function is not asynchronous.
There's probably a more flexible end-user abstraction than the try_write_all_chunks function I proposed above, but first wanted to get feedback on the idea. I'm happy to draft a PR for this if the idea seems generally useful.
There's currently no way in
quinn_proto::SendStream
(and consequentlyquinn::SendStream
) to perform all-or-nothing writes.As a concrete example, I have a
&mut [Bytes]
that I'd like to write to aquinn::SendStream
in its entirety if there's sufficient send capacity, or not at all. The end-user API could look something likefn try_write_all_chunks(&mut self, bufs: &mut [Bytes]) -> Result<(), WriteError>
- note that this function is not asynchronous.The current functionality seems to be a consequence of how
quinn_proto::write_source
works. It currently takes in aBytesSource
, acquires a lock, checks the write limit, and then writes from theBytesSource
up to the limit. https://github.com/quinn-rs/quinn/blob/dcc8048974ce9b1ca6b365019149b5586ed88f4a/quinn-proto/src/connection/streams/mod.rs#L205-L243 Conceptually, this could be implemented by augmentingquinn_proto::write_source
to also take inmin_limit
parameter.There's probably a more flexible end-user abstraction than the
try_write_all_chunks
function I proposed above, but first wanted to get feedback on the idea. I'm happy to draft a PR for this if the idea seems generally useful.