pub struct Receiver<E> { /* private fields */ }Expand description
A buffered stream of byte chunks.
The receiver yields chunks in insertion order. Its configured buffer size is a cooperative backpressure threshold for the sender, not a hard memory limit.
Implementations§
Source§impl<E> Receiver<E>
impl<E> Receiver<E>
Sourcepub fn set_watermarks(&self, high: u32, low: u32)
pub fn set_watermarks(&self, high: u32, low: u32)
Sets the sender backpressure watermarks.
Once buffered data reaches high bytes, Sender::poll_ready stops
reporting Status::Ready until the receiver drains the buffer to
low bytes or less, so the sender is not woken for every consumed
chunk. low is capped below high.
Sending does not enforce the watermarks, so producers must cooperate
by waiting for readiness. Changing the watermarks immediately updates
and, when needed, wakes sender readiness: the sender is ready if
buffered data is below high. The defaults are 32 KiB and 16 KiB.
Sourcepub fn max_buffer_size(&self, size: usize)
👎Deprecated since 4.2.0: Use Receiver::set_watermarks() instead
pub fn max_buffer_size(&self, size: usize)
Use Receiver::set_watermarks() instead
Sets the sender backpressure threshold.
Sets the high watermark to size and the low watermark to half of it.
Sourcepub fn put(&self, data: Bytes)
pub fn put(&self, data: Bytes)
Puts previously read data back at the front of the stream.
This may grow the buffer past its readiness threshold.
Sourcepub fn is_eof(&self) -> bool
pub fn is_eof(&self) -> bool
Returns true once EOF has been marked.
Buffered chunks may still be available after this returns true.
Trait Implementations§
Source§impl From<Receiver<PayloadError>> for Payload
impl From<Receiver<PayloadError>> for Payload
Source§fn from(v: Receiver<PayloadError>) -> Self
fn from(v: Receiver<PayloadError>) -> Self
Source§impl From<Receiver<PayloadError>> for Payload
impl From<Receiver<PayloadError>> for Payload
Source§fn from(rx: Receiver<PayloadError>) -> Self
fn from(rx: Receiver<PayloadError>) -> Self
Source§impl<E> Stream for Receiver<E>
impl<E> Stream for Receiver<E>
Source§fn poll_next(
self: Pin<&mut Receiver<E>>,
cx: &mut Context<'_>,
) -> Poll<Option<<Receiver<E> as Stream>::Item>>
fn poll_next( self: Pin<&mut Receiver<E>>, cx: &mut Context<'_>, ) -> Poll<Option<<Receiver<E> as Stream>::Item>>
None if the stream is exhausted. Read more