pub struct Payload { /* private fields */ }
Expand description
Buffered stream of byte chunks
Payload stores chunks in a vector. First chunk can be received with
.readany()
method. Payload stream is not thread safe. Payload does not
notify current task when new data is available.
Payload stream can be used as Response
body stream.
Implementations§
source§impl Payload
impl Payload
sourcepub fn create(cap: Capacity) -> (PayloadSender, Payload)
pub fn create(cap: Capacity) -> (PayloadSender, Payload)
Create payload stream.
This method construct two objects responsible for bytes stream generation.
-
PayloadSender
- Sender side of the stream -
Payload
- Receiver side of the stream
pub async fn read(&self) -> Option<Result<Bytes, PayloadError>>
pub fn poll_read( &self, cx: &mut Context<'_> ) -> Poll<Option<Result<Bytes, PayloadError>>>
Trait Implementations§
source§impl Stream for Payload
impl Stream for Payload
§type Item = Result<Bytes, PayloadError>
type Item = Result<Bytes, PayloadError>
Values yielded by the stream.
Auto Trait Implementations§
impl Freeze for Payload
impl !RefUnwindSafe for Payload
impl !Send for Payload
impl !Sync for Payload
impl Unpin for Payload
impl !UnwindSafe for Payload
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