pub struct Payload { /* private fields */ }Expand description
Buffered HTTP/2 payload stream.
Use Payload::read to receive the next chunk asynchronously, or consume
the payload through its Stream implementation. Waiting tasks are woken
when data, end-of-stream, or an error becomes available.
This type is not thread-safe and can also be used as a
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
Sourcepub async fn read(&self) -> Option<Result<Bytes, PayloadError>>
pub async fn read(&self) -> Option<Result<Bytes, PayloadError>>
Receives the next payload chunk.
Returns None after the complete payload has been received.
Trait Implementations§
Source§impl Stream for Payload
impl Stream for Payload
Auto Trait Implementations§
impl !RefUnwindSafe for Payload
impl !Send for Payload
impl !Sync for Payload
impl !UnwindSafe for Payload
impl Freeze for Payload
impl Unpin for Payload
impl UnsafeUnpin 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