Skip to main content

BodyStream

Trait BodyStream 

Source
pub trait BodyStream {
    // Required methods
    fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> BodyReadFuture<'a>;
    fn trailers(&mut self) -> BodyTrailersFuture<'_>;
    fn length(&self) -> Option<u64>;
}
Expand description

A body on its way to or from a server: bytes read a piece at a time, the length when the sender said it, and trailers once the body has ended. Read as FileStream is.

Required Methods§

Source

fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> BodyReadFuture<'a>

Reads the next bytes into buf, answering how many it read, 0 once the body has ended.

Source

fn trailers(&mut self) -> BodyTrailersFuture<'_>

The fields that came after the body, once it has ended; None where the response has none, and always None on a client whose protocol layer does not expose them.

Called only after read has answered 0; asking again answers the same fields, so an implementation over a future that may be awaited once keeps its answer. On a request body this answers the fields to send.

Source

fn length(&self) -> Option<u64>

How many bytes the whole body carries, when the sender said so, as Content-Length does. Undefined when the body is compressed or sent in pieces.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§