Skip to main content

BodySource

Trait BodySource 

Source
pub trait BodySource:
    AsyncRead
    + Send
    + 'static {
    // Required method
    fn trailers(self: Pin<&mut Self>) -> Option<Headers>;
}
Expand description

Trait for streaming body sources that can optionally produce trailers.

Implement this on types that compute trailer headers dynamically as the body is read — for example, a hashing wrapper that produces a Digest trailer after all bytes have been streamed.

For plain AsyncRead sources with no trailers, use Body::new_streaming. BodySource is only needed when trailers must be produced.

Required Methods§

Source

fn trailers(self: Pin<&mut Self>) -> Option<Headers>

Returns the trailers for this body, called after the body has been fully read.

Implementations may clear internal state on this call; the result is only meaningful after AsyncRead::poll_read has returned Ok(0).

Implementors§