pub struct ChunkedConsumer { /* private fields */ }Expand description
Reassembles segments produced by ChunkedProducer into the original payload.
Segments may arrive out of order; receive_segment inserts each one by
index. reassemble returns Some(Bytes) once all segments are present.
Implementations§
Source§impl ChunkedConsumer
impl ChunkedConsumer
Sourcepub fn new(prefix: Name, segment_count: usize) -> Self
pub fn new(prefix: Name, segment_count: usize) -> Self
Create a consumer expecting exactly segment_count segments.
pub fn prefix(&self) -> &Name
pub fn segment_count(&self) -> usize
Sourcepub fn receive_segment(&mut self, index: usize, payload: Bytes)
pub fn receive_segment(&mut self, index: usize, payload: Bytes)
Store the payload for index. Out-of-range indices are silently dropped.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns true when every segment has been received.
Sourcepub fn reassemble(&self) -> Option<Bytes>
pub fn reassemble(&self) -> Option<Bytes>
Concatenate all segments in order. Returns None if incomplete.
Auto Trait Implementations§
impl !Freeze for ChunkedConsumer
impl RefUnwindSafe for ChunkedConsumer
impl Send for ChunkedConsumer
impl Sync for ChunkedConsumer
impl Unpin for ChunkedConsumer
impl UnwindSafe for ChunkedConsumer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more