You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a request to add a recv like method to RecvStream, which yields Bytes but still ordered.
There are currently two main ways of reading data from a RecvStream:
read(&mut [u8]): This is an ordered read, but copies the data into a pre-allocated buffer.
read_unordered() -> (Bytes, u64): As the name implies, this is an unordered read, but it gives a Bytes object, which allows the user to receive those bytes without a copy.
In h3, when proving the h3<->quinn bridge, in order to try to reduce copies, we've been using the read_unordered. However, that means we end up having an intermediate collection to wait to put the Bytes in order, since we also need ordered reads. Since quinn is already doing that, it could be useful to provide a method that yields Bytes in an ordered manner. Looking in quinn's source, it'd probably be a simpler read, since it wouldn't need to handle partial reads into buffers, and can just yield a Bytes once the order is right.
So, the final method signature would be something like async fn recv(&mut self) -> Result<Option<Bytes>, ReadError>. (As a side note, if this is accepted, perhaps it might make sense to rename read_unordered to recv_unordered.)
The text was updated successfully, but these errors were encountered:
Good call, we should have this. There's a bunch of gotchas in making a robust stream assembler and we definitely don't want to incentivize callers to try to reimplement that.
This is a request to add a
recv
like method toRecvStream
, which yieldsBytes
but still ordered.There are currently two main ways of reading data from a
RecvStream
:read(&mut [u8])
: This is an ordered read, but copies the data into a pre-allocated buffer.read_unordered() -> (Bytes, u64)
: As the name implies, this is an unordered read, but it gives aBytes
object, which allows the user to receive those bytes without a copy.In h3, when proving the h3<->quinn bridge, in order to try to reduce copies, we've been using the
read_unordered
. However, that means we end up having an intermediate collection to wait to put theBytes
in order, since we also need ordered reads. Since quinn is already doing that, it could be useful to provide a method that yieldsBytes
in an ordered manner. Looking in quinn's source, it'd probably be a simplerread
, since it wouldn't need to handle partial reads into buffers, and can just yield aBytes
once the order is right.So, the final method signature would be something like
async fn recv(&mut self) -> Result<Option<Bytes>, ReadError>
. (As a side note, if this is accepted, perhaps it might make sense to renameread_unordered
torecv_unordered
.)The text was updated successfully, but these errors were encountered: