pub enum Payload {
None,
H1(Payload),
H2(Payload),
Stream(PayloadStream),
}Expand description
An HTTP request payload.
Variants§
None
No payload is available.
H1(Payload)
An HTTP/1 payload stream.
H2(Payload)
An HTTP/2 payload stream.
Stream(PayloadStream)
A custom payload stream.
Implementations§
Source§impl Payload
impl Payload
Sourcepub fn take(&mut self) -> Self
pub fn take(&mut self) -> Self
Takes the payload and replaces it with Payload::None.
Sourcepub fn from_stream<S>(stream: S) -> Self
pub fn from_stream<S>(stream: S) -> Self
Creates a payload from a local asynchronous byte stream.
The stream is pinned and does not need to implement Unpin. It must
yield HTTP PayloadError values directly.
Sourcepub async fn recv(&mut self) -> Option<Result<Bytes, PayloadError>>
pub async fn recv(&mut self) -> Option<Result<Bytes, PayloadError>>
Waits for and returns the next payload chunk.
Sourcepub fn poll_recv(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Bytes, PayloadError>>>
pub fn poll_recv( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, PayloadError>>>
Polls for the next payload chunk.
Registers the current task for wakeup when data is not yet available
and returns Poll::Ready(None) after the payload is exhausted.
Sourcepub fn trailers(&self) -> Option<HeaderMap>
pub fn trailers(&self) -> Option<HeaderMap>
Returns the trailer fields received at the end of the payload.
Trailers are available after the payload is complete. HTTP/1 chunked and HTTP/2 payloads provide trailers.
Sourcepub fn take_trailers(&self) -> Option<HeaderMap>
pub fn take_trailers(&self) -> Option<HeaderMap>
Takes the trailer fields received at the end of the payload.
Like Payload::trailers, without copying. Subsequent calls return None.