pub struct Chunks<'a> { /* private fields */ }
Expand description
Chunks returned from RecvStream::read()
.
§Note: Finalization Needed
Bytes read from the stream are not released from the congestion window until
either Self::finalize()
is called, or this type is dropped.
It is recommended that you call Self::finalize()
because it returns a flag
telling you whether reading from the stream has resulted in the need to transmit a packet.
If this type is leaked, the stream will remain blocked on the remote peer until another read from the stream is done.
Implementations§
Source§impl<'a> Chunks<'a>
impl<'a> Chunks<'a>
Sourcepub fn next(&mut self, max_length: usize) -> Result<Option<Chunk>, ReadError>
pub fn next(&mut self, max_length: usize) -> Result<Option<Chunk>, ReadError>
Next
Should call finalize() when done calling this.
Sourcepub fn finalize(self) -> ShouldTransmit
pub fn finalize(self) -> ShouldTransmit
Mark the read data as consumed from the stream.
The number of read bytes will be released from the congestion window, allowing the remote peer to send more data if it was previously blocked.
If ShouldTransmit::should_transmit()
returns true
,
a packet needs to be sent to the peer informing them that the stream is unblocked.
This means that you should call Connection::poll_transmit()
and send the returned packet as soon as is reasonable, to unblock the remote peer.